[jira] [Commented] (GROOVY-9880) Switch incorrectly falls through default case

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-9880) Switch incorrectly falls through default case

Eric Milles (Jira)

    [ https://issues.apache.org/jira/browse/GROOVY-9880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17264241#comment-17264241 ]

Eric Milles commented on GROOVY-9880:
-------------------------------------

This is a bug in the parser recovery additions that are part of the groovy-eclipse patches.

> 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)