Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-3
-
Fix Version/s: 1.1-rc-1
-
Component/s: None
-
Labels:None
-
Environment:OS: Win XP
Groovy Version: 1.1-beta-3
JVM: 1.6.0_02-b05
-
Number of attachments :
Description
The following doesn't work with Groovy 1.1 beta 3, neither in interpreted nor in compiled mode. Adding 'public' and/or 'final' to the declaration of 'temperature' doesn't change the picture. With beta 2 the program works in compiled but not in interpreted mode.
--------------------------------------------------------
E:\dev\tmp\test>type A.groovy
class A {
static def temperature = 42
}
E:\dev\tmp\test>type B.groovy
import static A.*
class B {
static def main(args) { println temperature }
}
E:\dev\tmp\test>groovy B
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
B.groovy: 4: the name temperature doesn't refer to a declared variable or class.
The static scope requires to declare variables before using them. If the variab
le should have been a class check the spelling.
@ line 4, column 35.
static def main(args) { println temperature }
^
1 error
E:\dev\tmp\test>groovyc *.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
B.groovy: 4: the name temperature doesn't refer to a declared variable or class.
The static scope requires to declare variables before using them. If the variab
le should have been a class check the spelling.
@ line 4, column 35.
static def main(args) { println temperature }
^
1 error
This is mostly fixed - moved the remaining static error detection parts into staticImportVisitor but I have a hack in place for one part - checking if Jochen has any ideas on a better way.