You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Isaac Dooley (JIRA)" <ji...@apache.org> on 2018/09/18 19:25:00 UTC

[jira] [Created] (GROOVY-8801) groovyc 2.5 and 3.0 fail to compile code with final variable set in try block

Isaac Dooley created GROOVY-8801:
------------------------------------

             Summary: groovyc 2.5 and 3.0 fail to compile code with final variable set in try block
                 Key: GROOVY-8801
                 URL: https://issues.apache.org/jira/browse/GROOVY-8801
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.5.2, 3.0.0-alpha-3
            Reporter: Isaac Dooley


Here is a simple example that fails to compile in 2.5.2 and 3.0.0-alpha3, but compiled successfully in 2.4.15. It seems that groovyc doesn't like that the variable is referenced in an unreachable portion of code should the assignment have never happened.
{code:java}
final Object v
try {
     v = "hello world"
} catch (Exception e) {
     throw new RuntimeException("goodbye")
}

println v{code}
 
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
./test2.groovy: 8: The variable [v] may be uninitialized
. At [8:9] @ line 8, column 9.
println v
        ^

1 error
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)