Issue Details (XML | Word | Printable)

Key: GROOVY-1307
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Guillaume Laforge
Reporter: Peter Ledbrook
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Parameter values not available in nested closures

Created: 04/May/06 04:54 AM   Updated: 01/Aug/06 04:45 AM   Resolved: 01/Aug/06 04:45 AM
Component/s: None
Affects Version/s: 1.0-JSR-5
Fix Version/s: 1.0-JSR-6

Time Tracking:
Not Specified

File Attachments: 1. File bug.groovy (1 kB)



 Description  « Hide

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.



Guillaume Laforge added a comment - 01/Aug/06 04:29 AM

Is it still a bug in JSR-06 ?


Peter Ledbrook added a comment - 01/Aug/06 04:42 AM

No. JSR-06 contains the fix.