You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/06/01 11:49:17 UTC

[jira] [Updated] (GROOVY-7442) spread-dot operator within assert isn't expected with @CompileStatic

     [ https://issues.apache.org/jira/browse/GROOVY-7442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King updated GROOVY-7442:
------------------------------
    Summary: spread-dot operator within assert isn't expected with @CompileStatic  (was: spread operator within assert isn't expected with @CompileStatic)

> spread-dot operator within assert isn't expected with @CompileStatic
> --------------------------------------------------------------------
>
>                 Key: GROOVY-7442
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7442
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.3
>            Reporter: Paul King
>
> This source:
> {code}
> @groovy.transform.CompileStatic
> def myMethod(String a, String b) {
>   assert [a, b]*.size() == [5, 5]
> }
> myMethod('hello', 'world')
> {code}
> Results in this compile error:
> {noformat}
> BUG! exception in phase 'class generation' in source unit 'ConsoleScript1' In method public java.lang.Object MyMethod(java.lang.String a, java.lang.String b)  { ... }, CompileStack#removeVar: tried to remove a temporary variable with index 3 in wrong order. Current temporary variables=[iterator(index=6,type=java.util.Iterator <E extends java.lang.Object -> java.lang.Object>,holder=false), recorder(index=3,type=java.lang.Object,holder=false)]
>     at org.codehaus.groovy.classgen.asm.CompileStack.removeVar(CompileStack.java:226)
>     at org.codehaus.groovy.classgen.asm.AssertionWriter.writeAssertStatement(AssertionWriter.java:136)
>     at org.codehaus.groovy.classgen.asm.StatementWriter.writeAssert(StatementWriter.java:550)
>     at org.codehaus.groovy.classgen.AsmClassGenerator.visitAssertStatement(AsmClassGenerator.java:587)
> */
> {noformat}
> but this compiles and runs fine:
> {code}
> @groovy.transform.CompileStatic
> def myMethod(String a, String b) {
>   def result = [a, b]*.size()
>   assert result == [5, 5]
> }
> myMethod('hello', 'world')
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)