Details
Description
The following one-liner script using multiple assignment crashes Groovy:
def (a,b) = [1,2]
I.e. when I type in console
groovy A.groovy
I get an error message:
Caught: BUG! exception in phase 'conversion' in source unit 'A.groovy'
org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
Interesting that the bug affects only Groovy 1.8.0 installed with Windows Installer. Groovy installed from ZIP works as expected.
Activity
Yes, I've chosen to install all available modules in the installer wizard. GroovyPP included.
I've just reinstalled without GroovyPP - and the problem has gone.
I close this as "Won't Fix", since this is then a groovypp issue and should must be fixed by them. I suggest you fill an issue there instead
OK, thanks. It turns out that such bug already exists - http://code.google.com/p/groovypptest/issues/detail?id=25
I got the same error running the SwingBuilder example at Home > Getting Started Guide > Feature Overview > GroovyMarkup on GroovyConsole.
Groovy script:
import groovy.swing.SwingBuilder;
def swing = new SwingBuilder()
def widget = swing.frame(title:'My Frame', defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE) {
panel() {
for (entry in someBean)
button(text:'OK', actionPerformed:{ println("I've been clicked with event $
{it}") })}
}
widget.show()
Error message:
groovy> import groovy.swing.SwingBuilder;
groovy> def swing = new SwingBuilder()
groovy> def widget = swing.frame(title:'My Frame', defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE) {
groovy> panel() {
groovy> for (entry in someBean) { groovy> label(text:entry.key) groovy> textField(text:entry.value) groovy> }
groovy> button(text:'OK', actionPerformed:{ println("I've been clicked with event ${it}
") })
groovy> }
groovy> }
groovy> widget.show()
Exception thrown
07/07/2011 16:12:41 org.codehaus.groovy.runtime.StackTraceUtils sanitize
AVISO: Sanitizing stacktrace:
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:101)
at org.mbte.groovypp.compiler.TraitASTTransform$GppParserPluginFactory$1.declarationExpression(TraitASTTransform.java:336)
at org.codehaus.groovy.antlr.AntlrParserPlugin.variableDef(AntlrParserPlugin.java:1452)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1202)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementListNoChild(AntlrParserPlugin.java:1276)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementList(AntlrParserPlugin.java:1264)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1194)
at org.codehaus.groovy.antlr.AntlrParserPlugin.ifStatement(AntlrParserPlugin.java:1368)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1223)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementListNoChild(AntlrParserPlugin.java:1276)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementList(AntlrParserPlugin.java:1264)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1194)
at org.codehaus.groovy.antlr.AntlrParserPlugin.ifStatement(AntlrParserPlugin.java:1368)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1223)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementListNoChild(AntlrParserPlugin.java:1276)
at org.codehaus.groovy.antlr.AntlrParserPlugin.statementList(AntlrParserPlugin.java:1264)
at org.codehaus.groovy.antlr.AntlrParserPlugin.methodDef(AntlrParserPlugin.java:795)
at org.codehaus.groovy.antlr.AntlrParserPlugin.objectBlock(AntlrParserPlugin.java:607)
at org.codehaus.groovy.antlr.AntlrParserPlugin.innerClassDef(AntlrParserPlugin.java:591)
at org.codehaus.groovy.antlr.AntlrParserPlugin.classDef(AntlrParserPlugin.java:502)
at org.codehaus.groovy.antlr.AntlrParserPlugin.convertGroovy(AntlrParserPlugin.java:284)
at org.codehaus.groovy.antlr.AntlrParserPlugin.buildAST(AntlrParserPlugin.java:241)
at org.codehaus.groovy.control.SourceUnit.convert(SourceUnit.java:272)
at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:618)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:520)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
at groovy.lang.GroovyShell.run(GroovyShell.java:516)
at groovy.lang.GroovyShell.run(GroovyShell.java:172)
at groovy.lang.GroovyShell$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:910)
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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)
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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.call(Closure.java:399)
at groovy.lang.Closure.run(Closure.java:483)
at java.lang.Thread.run(Thread.java:662)
07/07/2011 16:12:41 org.codehaus.groovy.runtime.StackTraceUtils sanitize
AVISO: Sanitizing stacktrace:
BUG! exception in phase 'conversion' in source unit 'file:/home/andrey/applications/eclipse/plugins/org.codehaus.groovy_1.8.0.xx-20110628-1600-e37/lib/groovy-1.8.0-sources.jar!/groovy/swing/factory/ColumnFactory.groovy' org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:843)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:520)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
at groovy.lang.GroovyShell.run(GroovyShell.java:516)
at groovy.lang.GroovyShell.run(GroovyShell.java:172)
at groovy.lang.GroovyShell$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:910)
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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)
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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.call(Closure.java:399)
at groovy.lang.Closure.run(Closure.java:483)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassCastException: org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
at org.mbte.groovypp.compiler.TraitASTTransform$GppParserPluginFactory$1.declarationExpression(TraitASTTransform.java:336)
BUG! exception in phase 'conversion' in source unit 'file:/home/andrey/applications/eclipse/plugins/org.codehaus.groovy_1.8.0.xx-20110628-1600-e37/lib/groovy-1.8.0-sources.jar!/groovy/swing/factory/ColumnFactory.groovy' org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
Caused by: java.lang.ClassCastException: org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
at org.mbte.groovypp.compiler.TraitASTTransform$GppParserPluginFactory$1.declarationExpression(TraitASTTransform.java:336)
did you install groovy++ as well?