You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/02/21 07:51:44 UTC

[jira] [Updated] (GROOVY-8094) Final variable analysis giving incorrect message within nested if

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

Paul King updated GROOVY-8094:
------------------------------
    Description: 
{code}
def method() {
    final z = null
    if (z != null) {
        z = 3
    }
}
{code}
gives error message:
{noformat}
1 compilation error:
The variable [z] may be uninitialized
. At [5:11]  at line: 5, column: 11
{noformat}
it should be a compile error since we are reassigning {{z}}, but the error message should be:
{noformat}
The variable [z] is declared final but is reassigned
{noformat}


  was:
{code}
def method() {
    final z = null
    if (z != null) {
        z = 3
    }
}
{code}
gives error message:
{noformat}
1 compilation error:
The variable [z] may be uninitialized
. At [5:11]  at line: 5, column: 11
{noformat}
but really the error message should be:
{noformat}
The variable [z] is declared final but is reassigned
{noformat}



> Final variable analysis giving incorrect message within nested if
> -----------------------------------------------------------------
>
>                 Key: GROOVY-8094
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8094
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>
> {code}
> def method() {
>     final z = null
>     if (z != null) {
>         z = 3
>     }
> }
> {code}
> gives error message:
> {noformat}
> 1 compilation error:
> The variable [z] may be uninitialized
> . At [5:11]  at line: 5, column: 11
> {noformat}
> it should be a compile error since we are reassigning {{z}}, but the error message should be:
> {noformat}
> The variable [z] is declared final but is reassigned
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)