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

Paul King updated GROOVY-9438:
------------------------------
    Fix Version/s:     (was: 3.0.2)
                       (was: 2.5.10)
                   2.5.11
                   3.0.3

> CLONE - Incorrect handling of final variables within switch
> -----------------------------------------------------------
>
>                 Key: GROOVY-9438
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9438
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniel Wilmer
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 3.0.3, 2.5.11
>
>
> The following code runs on groovy 2.4.18 but not on groovy 3.0.1.
> {code}
> static void main(String[] args) {
>     final String result
>     switch (2) {
>         case 1: result = "a"; break;
>         case 2: result = "b"; break;
>         default: result = "x"
>     }
>     println result
> }
> {code}
> *Error: Groovyc: The variable [result] is declared final but is reassigned.*
> Since we use final in our codebase a lot (although it seems to be ignored by 
> groovy 2.4), 
> we will have to adjust a lot of places to make our code groovy 3.0 compatible.



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

Reply via email to