[
https://issues.apache.org/jira/browse/GROOVY-9896?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles resolved GROOVY-9896.
---------------------------------
Fix Version/s: 4.0.0-alpha-3
Resolution: Fixed
> 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: 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)