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] [Updated] (GROOVY-3421) Expression underlying a spread map expression is evaluated twice
Date Mon, 01 Jun 2015 12:59:17 GMT

     [ 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)

Mime
View raw message