[
https://issues.apache.org/jira/browse/GROOVY-9880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17264241#comment-17264241 ]
Eric Milles edited comment on GROOVY-9880 at 1/13/21, 5:38 PM:
---------------------------------------------------------------
Changes made for GROOVY-9373 in {{ReturnAdder}} are to root cause.
https://github.com/apache/groovy/pull/1443/files#diff-907636c890966e51907d123f089d830c5b99a9b440e462e69a0b49f891f7ec02The {{BreakStatement}} is removed from the AST with the expectation that the remaining {{IfStatement}} will return from each branch.
was (Author: emilles):
Investigating...
> Switch incorrectly falls through default case
> ---------------------------------------------
>
> Key: GROOVY-9880
> URL:
https://issues.apache.org/jira/browse/GROOVY-9880> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.7
> Environment: Using Groovy-Eclipse 4.0.0 under Ubuntu 18.04
> Reporter: Javier MV
> Assignee: Eric Milles
> Priority: Minor
>
> When 'switch' is inside a Closure a weird condition causes 'default' case to be invoked, after another 'case' condition was met (even if 'break' was present).
> Minimal example:
> { it ->
> {{switch('a') {}}
> case 'a':
> print 'hi!'
> if (false)
> print 'x'
> break
> {{default: println 'bye'}}
> }
> {{}.call()}}
> Prints "hi!bye" as it is, but only "hi!" if outside the Closure. Adding an empty 'else \{ }' to the 'if' works as a poor man's fix.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)