Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.6.1.Release
-
Fix Version/s: 2.7.0.Release
-
Component/s: Compiler Integration
-
Labels:None
-
Environment:OS/X Lion, Eclipse 3.7.2
-
Number of attachments :
Description
If I have the following code in a Groovy class in an Eclipse project:
print "Foo" ===~ ".*"
...then this produces an internal error in the Groovy compiler when using Groovy version 1.8.6 (see stack trace below). However, this error is not reported in Eclipse. Instead, the class file for the file that contains this code isn't generated, hence other code that uses this class starts reporting errors.
This makes it very hard for a user to understand what's going on; only when trying to compile the offending file with the command line compiler does it become obvious what's happening. So I presume that Groovy-Eclipse ought to pick up such errors from the compiler and report them alongside other errors in Eclipse?
Stack trace:
>>> a serious error occurred: BUG! exception in phase 'class generation' in source unit '<...>Foo.groovy' Operation: ("===" at 2:13: "===" ) not supported
>>> stacktrace:
BUG! exception in phase 'class generation' in source unit '/Users/jans/src/courses/nlp-class/week4/pa4-ner/java/GroovyTest.groovy' Operation: ("===" at 2:13: "===" ) not supported
at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:246)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:521)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:301)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:187)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:89)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:73)
at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:292)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:657)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:577)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeReturn(OptimizingStatementWriter.java:316)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:499)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:313)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:270)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:390)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1056)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:174)
at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:767)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:967)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:546)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:149)
at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:179)
at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:163)
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.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Issue Links
- is related to
-
GROOVY-5500
GroovyBugError thrown when it shouldn't be
-
This is happening because the compiler is throwing an internal error on this bad syntax. Typically, we log internal errors in the error log, not in the file where the error comes from (since internal errors are not necessarily correlated with a file).
It seems to me that throwing an internal error here is not the right thing to do. Rather, a syntax error or something similar should be raised. These are handled correctly by our compiler.
I added a fix that will ensure that these {{GroovyBugError}}s are properly added to the list of compiler problems. Unfortunately, the error location will not be correct. I am closing this bug, but there is more work to do. I will raise an issue with groovy-core and see how we can raise a more appropriate compile error here.