Compiler BUG present in Groovy.3.0.0-alpha-1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler BUG present in Groovy.3.0.0-alpha-1

Kerridge, Jon

Hi,

I have just recompiled my system using Groovy3.0.0-alpha-1.  The same bug appears at the same line.


Error message:


Error:Groovyc: While compiling gppDemos: BUG! exception in phase 'class generation' in source unit 'D:\IJgroovy\gpp\gppDemos\src\demos\nQueensProblem\QueensClient.groovy' At line 67 column 13
On receiver: leftDiagonal with message: getAt and arguments: <not implemented yet for class: org.codehaus.groovy.classgen.asm.VariableSlotLoader>
This method should not have been called. Please try to create a simple example reproducing
this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:665)
    at org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:643)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:559)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:191)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:257)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:682)
    at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:60)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.loadWithSubscript(BinaryExpressionHelper.java:727)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluatePostfixMethod(BinaryExpressionHelper.java:655)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluatePostfixMethod(BinaryExpressionHelper.java:678)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitPostfixExpression(AsmClassGenerator.java:687)
    at org.codehaus.groovy.ast.expr.PostfixExpression.visit(PostfixExpression.java:45)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:625)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:664)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:610)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeIteratorBasedForEachLoop(StaticTypesStatementWriter.java:236)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeForInLoop(StaticTypesStatementWriter.java:91)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeForStatement(StatementWriter.java:97)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitForLoop(AsmClassGenerator.java:614)
    at org.codehaus.groovy.ast.stmt.ForStatement.visit(ForStatement.java:49)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:610)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:110)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:121)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:470)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:423)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:132)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:551)
    at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1095)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:261)
    at org.codehaus.groovy.control.CompilationUnit$18.call(CompilationUnit.java:848)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1088)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:631)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586)
    at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
    at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:158)
    at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.lambda$runGroovyc$0(InProcessGroovyc.java:88)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Code that causes the problem with the line causing is highlighted:


double doFitness(List <Integer> board) {
List <Integer> leftDiagonal = new ArrayList(2*N)
List <Integer> rightDiagonal = new ArrayList(2*N)
double sum = 0.0D

for ( i in 1 .. 2*N) {
leftDiagonal[i] = 0
rightDiagonal[i] = 0
}
for ( i in 1 .. N) {
leftDiagonal[i+board[i]-1]++
rightDiagonal[N-i+board[i]]++
}
for ( i in 1 .. ((2*N) - 1)) {
int counter = 0
if ( leftDiagonal[i] > 1)
counter += leftDiagonal[i] - 1
if ( rightDiagonal[i] > 1)
counter += rightDiagonal[i] - 1
sum += counter / (N - Math.abs(i-N))
}
// target fitness is 0.0
// sum can be negative so return absolute value
return Math.abs(sum)
}

Thus  the code compiles with Groovy.2.4.12 but not with other later 2.4 versions, or 2.5 or the 3.0.0 versions.  I have not tried the 2.6 version.

I have checked the version of Groovy I was using in Eclipse prior to moving to Intellij and that was 2.4.11.  On moving to Intellij I first started with 2.4.12 then moved to 2.5 at which point the problem occured.

Hope this helps in trying to find the problem.

Jon

Professor Jon Kerridge
School of Computing
Edinburgh Napier University
Merchiston Campus
Edinburgh EH10 5DT
 
0131 455 2777
 

This message and its attachment(s) are intended for the addressee(s) only and should not be read, copied, disclosed, forwarded or relied upon by any person other than the intended addressee(s) without the permission of the sender. If you are not the intended addressee you must not take any action based on this message and its attachment(s) nor must you copy or show them to anyone. Please respond to the sender and ensure that this message and its attachment(s) are deleted.

It is your responsibility to ensure that this message and its attachment(s) are scanned for viruses or other defects. Edinburgh Napier University does not accept liability for any loss or damage which may result from this message or its attachment(s), or for errors or omissions arising after it was sent. Email is not a secure medium. Emails entering Edinburgh Napier University's system are subject to routine monitoring and filtering by Edinburgh Napier University.

Edinburgh Napier University is a registered Scottish charity. Registration number SC018373

Reply | Threaded
Open this post in threaded view
|

Re: Compiler BUG present in Groovy.3.0.0-alpha-1

paulk_asert
Here is a simpler reproducer:

import groovy.transform.CompileStatic

@CompileStatic
def method() {
  def list = [0, 1, 2, 3]
  for (idx in 1..2) {
    list[idx-1]++
  }
  list
}

assert method() == [1, 2, 2, 3]


On Tue, Apr 17, 2018 at 2:05 AM, Kerridge, Jon <[hidden email]> wrote:

Hi,

I have just recompiled my system using Groovy3.0.0-alpha-1.  The same bug appears at the same line.


Error message:


Error:Groovyc: While compiling gppDemos: BUG! exception in phase 'class generation' in source unit 'D:\IJgroovy\gpp\gppDemos\src\demos\nQueensProblem\QueensClient.groovy' At line 67 column 13
On receiver: leftDiagonal with message: getAt and arguments: <not implemented yet for class: org.codehaus.groovy.classgen.asm.VariableSlotLoader>
This method should not have been called. Please try to create a simple example reproducing
this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:665)
    at org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:643)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:559)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:191)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:257)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:682)
    at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:60)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.loadWithSubscript(BinaryExpressionHelper.java:727)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluatePostfixMethod(BinaryExpressionHelper.java:655)
    at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluatePostfixMethod(BinaryExpressionHelper.java:678)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitPostfixExpression(AsmClassGenerator.java:687)
    at org.codehaus.groovy.ast.expr.PostfixExpression.visit(PostfixExpression.java:45)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:625)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:664)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:610)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeIteratorBasedForEachLoop(StaticTypesStatementWriter.java:236)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeForInLoop(StaticTypesStatementWriter.java:91)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeForStatement(StatementWriter.java:97)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitForLoop(AsmClassGenerator.java:614)
    at org.codehaus.groovy.ast.stmt.ForStatement.visit(ForStatement.java:49)
    at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
    at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:610)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:110)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:121)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:470)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:423)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:132)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:551)
    at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1095)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54)
    at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:261)
    at org.codehaus.groovy.control.CompilationUnit$18.call(CompilationUnit.java:848)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1088)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:631)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586)
    at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
    at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:158)
    at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.lambda$runGroovyc$0(InProcessGroovyc.java:88)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Code that causes the problem with the line causing is highlighted:


double doFitness(List <Integer> board) {
List <Integer> leftDiagonal = new ArrayList(2*N)
List <Integer> rightDiagonal = new ArrayList(2*N)
double sum = 0.0D

for ( i in 1 .. 2*N) {
leftDiagonal[i] = 0
rightDiagonal[i] = 0
}
for ( i in 1 .. N) {
leftDiagonal[i+board[i]-1]++
rightDiagonal[N-i+board[i]]++
}
for ( i in 1 .. ((2*N) - 1)) {
int counter = 0
if ( leftDiagonal[i] > 1)
counter += leftDiagonal[i] - 1
if ( rightDiagonal[i] > 1)
counter += rightDiagonal[i] - 1
sum += counter / (N - Math.abs(i-N))
}
// target fitness is 0.0
// sum can be negative so return absolute value
return Math.abs(sum)
}

Thus  the code compiles with Groovy.2.4.12 but not with other later 2.4 versions, or 2.5 or the 3.0.0 versions.  I have not tried the 2.6 version.

I have checked the version of Groovy I was using in Eclipse prior to moving to Intellij and that was 2.4.11.  On moving to Intellij I first started with 2.4.12 then moved to 2.5 at which point the problem occured.

Hope this helps in trying to find the problem.

Jon

Professor Jon Kerridge
School of Computing
Edinburgh Napier University
Merchiston Campus
Edinburgh EH10 5DT
 
0131 455 2777
 

This message and its attachment(s) are intended for the addressee(s) only and should not be read, copied, disclosed, forwarded or relied upon by any person other than the intended addressee(s) without the permission of the sender. If you are not the intended addressee you must not take any action based on this message and its attachment(s) nor must you copy or show them to anyone. Please respond to the sender and ensure that this message and its attachment(s) are deleted.

It is your responsibility to ensure that this message and its attachment(s) are scanned for viruses or other defects. Edinburgh Napier University does not accept liability for any loss or damage which may result from this message or its attachment(s), or for errors or omissions arising after it was sent. Email is not a secure medium. Emails entering Edinburgh Napier University's system are subject to routine monitoring and filtering by Edinburgh Napier University.

Edinburgh Napier University is a registered Scottish charity. Registration number SC018373