groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-8030) An unexpected error has occurred when using 'kkk = kkk + 12'
Date Thu, 02 Feb 2017 23:08:51 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15842527#comment-15842527
] 

Paul King edited comment on GROOVY-8030 at 2/2/17 11:08 PM:
------------------------------------------------------------

A smaller example illustrating the issue:
{code}
@groovy.transform.CompileStatic
def main() {
    def kkk = "abc"
    kkk = 30
    kkk + 12 // BUG! exception in phase 'class generation'
}

assert main() == 42
{code}
It's using the LUB and Serializable doesn't have {{plus}} but it shouldn't be using LUB here.


was (Author: paulk):
A smaller example illustrating the issue:
{code}
@groovy.transform.CompileStatic
def main() {
  def kkk = "123"
  kkk = 789
  kkk = kkk + 12 // BUG! exception in phase 'class generation'
}
{code}
It's using the LUB and Serializable doesn't have {{plus}} but it shouldn't be using LUB here.

> An unexpected error has occurred when using 'kkk = kkk + 12'
> ------------------------------------------------------------
>
>                 Key: GROOVY-8030
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8030
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.5
>         Environment: java.version=1.8.0_45
> java.runtime.version=1.8.0_45-b15
> os.arch=x86
> os.name=Windows 7
> sun.jnu.encoding=GBK
>            Reporter: XueJun
>
> Test groovy code:
> ------------------------------------
> {code:Java}
> package com.test
> def kkk = 123
> kkk = "123"
> println kkk.toInteger()
> int a = 0;
> if (a > 0)
> {
>   kkk = 789
>   kkk = kkk + 12 // This code caused error occur
> }
> else
> {
>   kkk = "456"
>   kkk = kkk + "78"
> }
> //println kkk.toUpperCase()
> println kkk
> {code}
> Error message:
> ------------------------------------
> {noformat}
> Exception in thread "main" BUG! exception in phase 'class generation' in source unit
'SimpleDemo' At line 13 column 9
> On receiver: kkk with message: plus and arguments: 12
> This method should not have been called. Please try to create a simple example reproducing
this error and filea bug report at https://issues.apache.org/jira/browse/GROOVY
> 	at org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:634)
> 	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:616)
> 	at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:529)
> 	at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:230)
> 	at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:148)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:638)
> 	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
> 	at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:316)
> 	at org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:151)
> 	at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:84)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:638)
> 	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
> 	at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:607)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:620)
> 	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
> 	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:84)
> 	at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:566)
> 	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
> 	at org.codehaus.groovy.classgen.asm.StatementWriter.writeIfElse(StatementWriter.java:288)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitIfElse(AsmClassGenerator.java:582)
> 	at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:43)
> 	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:84)
> 	at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:65)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:566)
> 	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:430)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:387)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:507)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1086)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:233)
> 	at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:813)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1055)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
> 	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
> 	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
> 	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
> 	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:694)
> 	at groovy.lang.GroovyShell.parse(GroovyShell.java:706)
> 	at groovy.lang.GroovyShell.parse(GroovyShell.java:742)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message