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 2015/06/01 14:59:17 UTC

[jira] [Updated] (GROOVY-3421) Expression underlying a spread map expression is evaluated twice

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

Paul King updated GROOVY-3421:
------------------------------
    Affects Version/s:     (was: 2.4.0-rc-2)
                       2.4.3

> Expression underlying a spread map expression is evaluated twice
> ----------------------------------------------------------------
>
>                 Key: GROOVY-3421
>                 URL: https://issues.apache.org/jira/browse/GROOVY-3421
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 1.7-beta-1, 2.2.0-beta-1, 2.4.3
>            Reporter: Peter Niederwieser
>
> {code}
> class SpreadMapBug extends GroovyTestCase {
>     void test() {
>         def x = 0
>         assertEquals([a:1, b:1], [a:1, *:[b:++x]]) // fails; actual value: [a:1, b:2]
>     }
> }
> {code}
> Maybe this bug is related to the (strange) AST representation for a spread map expression (at least that's how I found the bug):
> "*:[b:++x]" is a MapEntryExpression whose 
>  - key is a SpreadMapExpression whose expression is a MapExpression representing "[b:++x]"
>  - value is a MapExpression representing "[b:++x]".
> That makes _two_ MapExpressionS...



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