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

Parameter values not available in nested closures

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0-JSR-6
    • None
    • None

    Description

      If a closure nested at a level greater than or equal to 2 accesses a method parameter, it does not read that parameter's value - rather it uses the reference itself as the value. This is difficult to explain, but I have attached a reproduction recipe to highlight the problem.

      I don't know whether this is specific to builders or not, but I suspect it is probably a general problem. Strangely, local variables declared within the method are read correctly. This at least means that there is a reasonable workaround, which is to assign the problem parameter values to local variables.

      Attachments

        1. bug.groovy
          1 kB
          Peter Ledbrook

        Activity

          People

            guillaume Guillaume Sauthier
            pledbrook Peter Ledbrook
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: