The following test reports a compilation error:
def testMultipleAssignment() {
setup:
File file = new File('x')
when:
def (x,y,z) = [1,2,3]
then:
x == 1
y == 2
z == 3
cleanup:
file?.delete()
}
Spock version: 0.7-groovy-2.0; Groovy version: 2.1.2
Here it is the error stack trace:
Groovyc: Unexpected error during compilation of spec 'ListTest'. Maybe you have
used invalid Spock syntax? Anyway, please file a bug report at
http://issues.spockframework.org.
java.lang.ClassCastException:
org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to
org.codehaus.groovy.ast.expr.VariableExpression
at org.codehaus.groovy.ast.expr.DeclarationExpression.getVariableExpression(DeclarationExpression.java:103)
at org.spockframework.compiler.SpecRewriter.moveVariableDeclarations(SpecRewriter.java:538)
at org.spockframework.compiler.SpecRewriter.visitCleanupBlock(SpecRewriter.java:371)
at org.spockframework.compiler.model.CleanupBlock.accept(CleanupBlock.java:33)
at org.spockframework.compiler.model.Method.accept(Method.java:70)
at org.spockframework.compiler.model.Spec.accept(Spec.java:113)
at org.spockframework.compiler.SpockTransform$Impl.processSpec(SpockTransform.java:77)
at org.spockframework.compiler.SpockTransform$Impl.visit(SpockTransform.java:64)
at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:47)
at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:319)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:575)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:551)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:528)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:46)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:112)
Original issue reported on code.google.com by paolo.ditommaso on 23 Mar 2013 at 9:33
Original issue reported on code.google.com by
paolo.ditommaso
on 23 Mar 2013 at 9:33