You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/02 20:15:00 UTC

[jira] [Updated] (GROOVY-9896) Switch return statement transformation misses last case without break

     [ https://issues.apache.org/jira/browse/GROOVY-9896?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-9896:
--------------------------------
    Fix Version/s: 3.0.8

> Switch return statement transformation misses last case without break
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-9896
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9896
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.14, 3.0.7, 4.0.0-alpha-2
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.8, 4.0.0-alpha-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> def test(str) {
>   switch(str) {
>    case 'foo':
>    case 'bar':
>     'value'
>   //break
>   }
> }
> println test('foo')
> println test('bar')
> println test('baz')
> {code}
> When this script is executed, it prints "null" three times.  If the break statement is added, it prints "value", "value", "null" as expected.  {{ReturnAdder}} only transforms case blocks that end with break.  This is possibly the reason GROOVY-4727 fails.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)