groovy

Enums error

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.5.5, 1.6-beta-1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

The code:

enum Test {
}

def Test

This empty enum gives the error:
Exception thrown: BUG! exception in phase 'semantic analysis' in source unit 'Script86' null

Activity

Hide
tim orr added a comment -

I have tested this in IDEA and via command line and can not replicate any exception or an issue with an empty enum.

Do you have any other code that will reproduce this exception?
or
Is this fixed with the latest build?

I'm running against Groovy 1.5.4

Show
tim orr added a comment - I have tested this in IDEA and via command line and can not replicate any exception or an issue with an empty enum. Do you have any other code that will reproduce this exception? or Is this fixed with the latest build? I'm running against Groovy 1.5.4
Hide
Musachy Barroso added a comment -

I can replicate this on trunk, the problem is in EnumVisitor lines 294, and 295, because the enum is empty tempMax and tempMin are null.

here is an stack trace:

BUG! exception in phase 'semantic analysis' in source unit 'C:\src\groovy\groovy-core\src\test\groovy\SampleMain.groovy' null
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:788)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:449)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:277)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:248)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:188)
at groovy.lang.GroovyShell$2.run(GroovyShell.java:204)
at java.security.AccessController.doPrivileged(Native Method)
at groovy.lang.GroovyShell.run(GroovyShell.java:202)
at org.codehaus.groovy.classgen.MainTest.testMainMethod(MainTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
at org.codehaus.groovy.ast.expr.FieldExpression.getFieldName(FieldExpression.java:45)
at org.codehaus.groovy.classgen.VariableScopeVisitor.visitFieldExpression(VariableScopeVisitor.java:428)
at org.codehaus.groovy.ast.expr.FieldExpression.visit(FieldExpression.java:37)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBinaryExpression(CodeVisitorSupport.java:132)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:64)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:159)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:38)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:129)
at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:347)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:52)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:73)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:80)
at org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(VariableScopeVisitor.java:464)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:88)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:880)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:48)
at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClass(VariableScopeVisitor.java:446)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:536)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:784)
... 26 more

Show
Musachy Barroso added a comment - I can replicate this on trunk, the problem is in EnumVisitor lines 294, and 295, because the enum is empty tempMax and tempMin are null. here is an stack trace: BUG! exception in phase 'semantic analysis' in source unit 'C:\src\groovy\groovy-core\src\test\groovy\SampleMain.groovy' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:788) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:449) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:277) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:248) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:188) at groovy.lang.GroovyShell$2.run(GroovyShell.java:204) at java.security.AccessController.doPrivileged(Native Method) at groovy.lang.GroovyShell.run(GroovyShell.java:202) at org.codehaus.groovy.classgen.MainTest.testMainMethod(MainTest.java:61) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.NullPointerException at org.codehaus.groovy.ast.expr.FieldExpression.getFieldName(FieldExpression.java:45) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitFieldExpression(VariableScopeVisitor.java:428) at org.codehaus.groovy.ast.expr.FieldExpression.visit(FieldExpression.java:37) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBinaryExpression(CodeVisitorSupport.java:132) at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:64) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:159) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:38) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:129) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:347) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:52) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:73) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:80) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(VariableScopeVisitor.java:464) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:88) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:880) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:48) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClass(VariableScopeVisitor.java:446) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:536) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:784) ... 26 more
Hide
Musachy Barroso added a comment -

my bad, lines 294 and 303

Show
Musachy Barroso added a comment - my bad, lines 294 and 303
Hide
tim orr added a comment -

my bad, I didn't update my IDE with 1.5.4 and I still had several groovy jars on my classpath.

I was able to reproduce it, and locally (command and IDEA) was able to workaround the issue with
enum Test {
Bob
}

the def Test had nothing to do with the bug issue I saw.

the following will not work tho because Test is nothing, and it doesn't know that Test.Bob exists... however, I don't consider this a bug, just natural selection of Duck Typing

enum Test {
Bob
}

def Test
println Test.Bob

Show
tim orr added a comment - my bad, I didn't update my IDE with 1.5.4 and I still had several groovy jars on my classpath. I was able to reproduce it, and locally (command and IDEA) was able to workaround the issue with enum Test { Bob } the def Test had nothing to do with the bug issue I saw. the following will not work tho because Test is nothing, and it doesn't know that Test.Bob exists... however, I don't consider this a bug, just natural selection of Duck Typing enum Test { Bob } def Test println Test.Bob
Hide
blackdrag blackdrag added a comment -

the bug is fixed in 1.6 for now. Thanks for identifying the issue, a merge to 1.5.5 will follow soon

Show
blackdrag blackdrag added a comment - the bug is fixed in 1.6 for now. Thanks for identifying the issue, a merge to 1.5.5 will follow soon
Hide
Paul King added a comment -

Just tweaked the test. This fix still needs to be merged to 1.5.5 and then removed from the list of merge exclusions in CHANGESET-INFO.txt

Show
Paul King added a comment - Just tweaked the test. This fix still needs to be merged to 1.5.5 and then removed from the list of merge exclusions in CHANGESET-INFO.txt
Hide
blackdrag blackdrag added a comment -

the enum problem itself is fixed, but the stub generator fails to create a stub for it... another issue is filled, the stub problem is not in 1.6

Show
blackdrag blackdrag added a comment - the enum problem itself is fixed, but the stub generator fails to create a stub for it... another issue is filled, the stub problem is not in 1.6

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: