Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-1
-
Fix Version/s: 1.1-beta-2
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
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 = { 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
// }
}
looks like the resulting map was not packed into a Object[] for the call.. fixed now