Issue Details (XML | Word | Printable)

Key: GROOVY-1967
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Joachim Baumann
Votes: 0
Watchers: 0
Operations

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

When assigned to a local variable or attribute, a closure with named parameters throws a verify error

Created: 03/Jul/07 08:16 AM   Updated: 03/Jul/07 10:28 AM
Component/s: None
Affects Version/s: 1.1-beta-1
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide
When assigned to a local variable or attribute, a closure with named parameters throws a verify error.

However, if the closure is called directly upon creation (i.e. without intermediate assignment to a variable), then the call works without problems.
The same holds true if in a script the Binding is used to store the closure reference instead of a variable.

Here is a test case. The commented test methods throw the verify error.

class ClosureNamedParameters extends GroovyTestCase {

// void testClosureAsLocalVar() {
// def local = { Map params -> // params.x * params.y // }
// assert local(x : 2, y : 3) == 6
// }
void testClosureDirectly() {
assert { Map params -> params.x * params.y }(x : 2, y : 3) == 6
}
// def attribute
// void testClosureAsAttribute() {
// attribute = { Map params ->// params.x * params.y// } }
// assert attribute(x : 2, y : 3) == 6
// }
}



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou added a comment - 03/Jul/07 10:28 AM
looks like the resulting map was not packed into a Object[] for the call.. fixed now