groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8386) Final variable analysis broken with try/catch/finally
Date Sun, 19 Nov 2017 12:26:00 GMT
Paul King created GROOVY-8386:
---------------------------------

             Summary: Final variable analysis broken with try/catch/finally
                 Key: GROOVY-8386
                 URL: https://issues.apache.org/jira/browse/GROOVY-8386
             Project: Groovy
          Issue Type: Bug
            Reporter: Paul King


In this code:
{code}
final begin
try {
  begin = new Date()
} finally {
  println 'done'
}
{code}
The current error is:
{noformat}
The variable [begin] may be uninitialized
{noformat}
But this should only happen if begin is used in the catch or finally blocks or prior to the
first assignment.

This impacts Spock usage since it converts the following into something similar to above:
{code}
@Grab('org.spockframework:spock-core:1.1-groovy-2.4-SNAPSHOT')
@GrabExclude('org.codehaus.groovy:groovy-all')
import spock.lang.Specification

class DummySpec extends Specification {
    def 'FVA when using Spock'() {
        given:
        final begin = new Date()

        cleanup:
        println 'done'
    }
}
{code}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message