groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7958) Incorrect parsing of comma-separated variable declaration as single statement after if/while/for
Date Wed, 05 Oct 2016 08:12:20 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15548025#comment-15548025
] 

ASF GitHub Bot commented on GROOVY-7958:
----------------------------------------

GitHub user paulk-asert opened a pull request:

    https://github.com/apache/groovy/pull/437

    GROOVY-7958: Incorrect parsing of comma-separated variable declaratio…

    …n as single statement after if/while/for

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paulk-asert/groovy groovy7958

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/437.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #437
    
----
commit baca8ea46a7d02b26832fcb58ba0b1e4ecdd620b
Author: paulk <paulk@asert.com.au>
Date:   2016-10-05T08:05:43Z

    GROOVY-7958: Incorrect parsing of comma-separated variable declaration as single statement
after if/while/for

----


> Incorrect parsing of comma-separated variable declaration as single statement after if/while/for
> ------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7958
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7958
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Assignee: Paul King
>
> Currently during parsing a single (comma-separated) variable declaration is turned into
multiple statements on the fly. If this occurs when such a statement is the single statement
after an if/while/for, then only the first statement is picked up and the next is left dangling
within the AST tree. For 'if' it becomes the else statement! while in the 'for/while' cases
I think it is ignored. So, the following code doesn't work as expected:
> {code}
> int xNext = 0, yNext = 0
> if (false) int x = xNext++, y = yNext++
> assert xNext == 0 && yNext == 0
> if (true) int x = xNext++, y = yNext++
> assert xNext == 1 && yNext == 1
> {code}
> This is very much an edge case (what good is a declaration if you then have no block
in which to use it?) but is still worth fixing.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message