Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.7.3
-
None
-
Windows 7
Description
This code:
class Crasher { public void m() { def fields = [1,2,3] def expectedFieldNames = ["patentnumber", "status"]. for (int i=0; i<fields.size(); i++) { Object f = fields[i] System.out.println(f); } } }
is not valid (I believe?). There is an extraneous '.' on the end of the second 'def' line. Instead of a nice error message about having done something wrong, we get this stack on compilation:
>>> a serious error occurred: BUG! exception in phase 'class generation' in source unit 'Crasher.groovy' tried to get a variable wit h the name i as stack variable, but a variable with this name was not created >>> stacktrace: BUG! exception in phase 'class generation' in source unit 'Crasher.groovy' tried to get a variable with the name i as stack variable , but a variable with this name was not created at org.codehaus.groovy.classgen.CompileStack.getVariable(CompileStack.java:263) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClosureExpression(AsmClassGenerator.java:1759) at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:46) at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4071) at org.codehaus.groovy.classgen.AsmClassGenerator.makeCallSite(AsmClassGenerator.java:2147) at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:1984) at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:1970) at org.codehaus.groovy.classgen.AsmClassGenerator.makeInvokeMethodCall(AsmClassGenerator.java:1953) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:2300) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:72) at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4071) at org.codehaus.groovy.classgen.AsmClassGenerator.assignmentCastAndVisit(AsmClassGenerator.java:4012) at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateEqual(AsmClassGenerator.java:3962) at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:1442) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:53) at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4071) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:1430) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)