groovy
  1. groovy
  2. GROOVY-3421

Expression underlying a spread map expression is evaluated twice

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7-beta-1, 2.2.0-beta-1, 2.4.0-beta-3
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      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]
          }
      }
      

      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...

        Activity

        blackdrag blackdrag made changes -
        Field Original Value New Value
        Fix Version/s 1.5.8 [ 14630 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Fix Version/s 1.6.1 [ 14852 ]
        Paul King made changes -
        Description 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]
            }
        }

        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...
        {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...
        Guillaume Laforge made changes -
        Fix Version/s 1.6.1 [ 14852 ]
        Fix Version/s 1.6.2 [ 15151 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.5.8 [ 14630 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.6.3 [ 15251 ]
        Fix Version/s 1.6.2 [ 15151 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.6.3 [ 15251 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.7-beta-x [ 15538 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        blackdrag blackdrag made changes -
        Fix Version/s 1.8.x [ 15750 ]
        Fix Version/s 2.x [ 17013 ]
        Fix Version/s 1.7.x [ 15538 ]
        Pascal Schumacher made changes -
        Fix Version/s 1.8.x [ 15750 ]
        Fix Version/s 2.x [ 17013 ]
        Affects Version/s 2.2.0-beta-1 [ 19074 ]
        Pascal Schumacher made changes -
        Affects Version/s 2.4.0-beta-3 [ 20544 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Peter Niederwieser
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: