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 2018/05/18 21:40:00 UTC
[jira] [Commented] (GROOVY-8571) Variable [XXX] is declared final
but is reassigned false positive error
[ https://issues.apache.org/jira/browse/GROOVY-8571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16481228#comment-16481228 ]
Paul King commented on GROOVY-8571:
-----------------------------------
I haven't found a good solution for that issue on the Groovy side. I am hoping to create a PR for Spock to address the issue but haven't had time yet.
Basically if you have:
{code:java}
def x = 'foo'
{code}
and a {{cleanup:}} clause Spock creates code like:
{code}
def x
try {
x = 'foo'
} catch(...) {
} finally {
// cleanup code here
}
{code}
This is appropriate if x appears in the cleanup code but even if a variable is not mentioned in the cleanup code it is split up this way if a {{cleanup:}} clause is present. My preferred option is a fix for Spock that would leave such variables untouched, e.g. you could have {{final y = 'bar'}} and as long as y didn't appear in the cleanup code, the declaration for y would be untouched.
> Variable [XXX] is declared final but is reassigned false positive error
> -----------------------------------------------------------------------
>
> Key: GROOVY-8571
> URL: https://issues.apache.org/jira/browse/GROOVY-8571
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.0-rc-2
> Reporter: paolo di tommaso
> Priority: Major
>
> Groovy version 2.5.0-rc-2 may report false positive final variable reassignment compilation errors.
> For example:
> {code}
> MailerTest.groovy: -1: The variable [PORT] is declared final but is reassigned
> {code}
> The source code is available at [this link|https://github.com/nextflow-io/nextflow/blob/90f8dcc5d413af06a76e8f7b3e37c5616f721024/src/test/groovy/nextflow/mail/MailerTest.groovy#L120].
> To replicate the issue follow these steps
> {code}
> git clone https://github.com/nextflow-io/nextflow.git
> cd nextflow
> CI_GROOVY_VERSION=2.5.0-rc-2 make clean compile test
> {code}
> Curiously, the CI server build is [reporting a slight version of the same issue|http://ci.groovy-lang.org/viewLog.html?buildId=49488&tab=buildResultsDiv&buildTypeId=JointBuilds_Nextflow_Groovy25xJointBuild#] including sometimes the correct line number instead of -1.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)