Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5046

incorrect result when using += operator in closure

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 1.8.3, 1.9-beta-4
    • Component/s: parser
    • Labels:
      None
    • Environment:
      Linux

      Description

      I get incorrect result running the following script with groovy 1.8.2:

      a=[3:5]
      
      class B {
              int v;
      }
      
      B b = new B();
      b.v = 3
      
      clos = {
              if (it!=null)
              {
                      a[it.v] += 3
              }
      }
      clos.call(b)
      
      println 'b.v = ' + b.v
      println 'a = ' + a
      

      > groovy test.groovy
      b.v = 8
      a = 8

        Attachments

          Activity

            People

            • Assignee:
              blackdrag Jochen Theodorou
              Reporter:
              shumin Shu-Min Yang
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: