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

Tommy Svensson commented on GROOVY-8036:
----------------------------------------

{code}
package se.natusoft.osgi.aps.net.messaging.vertx

import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.junit.Test

@CompileStatic // <-- important!
class GroovyBugTest {

    @Test
    void groovyBugTest() {
       [1..5]. each { ->
           println "x"
       }
    }
}
{code}

This will produce the NPE. It only happens with @CompileStatic. Without 
@CompileStatic you get a nice error message.


> Compiler throws NPE
> -------------------
>
>                 Key: GROOVY-8036
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8036
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.7
>            Reporter: Tommy Svensson
>
> With code like this:
> int a = 5
> [1..a].each { ->
>    println "qwerty"
> }
> the compiler throws an NPE. OK, this is incorrect code since it is missing a 
> value before '->', but this should preferably produce an error message and 
> not an NPE :-)



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

Reply via email to