Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1-beta-1
-
None
-
None
Description
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 =
// 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
// }
}