Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: 1.0-JSR-6
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:JSR-6, JDK1.5, Windows XP
Description
The simple script:
println "Hello World"
final foo = "Foo is final"
println foo
foo = "Yet foo has changed"
println foo
outputs:
Hello World
Foo is final
Yet foo has changed
groovy should error when the final variable foo is re-assigned
Issue Links
- duplicates
-
GROOVY-1628
Inconsistent checking of final
-
I'm not sure if this is a bug or not as 'foo' is a variable in the Binding so the final modifier is not applied. But if the final keyword is used with a class property then it will work as expected.
If final should work at script level, should static and access modifiers too?