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

incorrect result when using += operator in closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.2
    • 1.8.3, 1.9-beta-4
    • parser
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: