Skip to content

Instantly share code, notes, and snippets.

@alien11689
Created July 21, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alien11689/8c31b65e42923eb49849e36d55fbf6ca to your computer and use it in GitHub Desktop.
Save alien11689/8c31b65e42923eb49849e36d55fbf6ca to your computer and use it in GitHub Desktop.
$ groovy -version
Groovy Version: 2.4.7 JVM: 1.8.0_91 Vendor: Oracle Corporation OS: Linux
$ groovy test.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/alien/test.groovy: 6: Apparent variable 'name' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'name' but left out brackets in a place not allowed by the grammar.
@ line 6, column 16.
return name
^
1 error
@groovy.transform.CompileStatic
class A {
String name
static String hello() {
return name
}
}
println(new A(name: 'aaaa').hello())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment