Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0-beta-9
-
Fix Version/s: 1.0-JSR-6
-
Component/s: None
-
Labels:None
-
Environment:Windows XP
-
Number of attachments :
Description
A statically typed variable in a method cannot be assigned an
incompatible type. However, the same code works dynamically
when used outside a method. See following:
def doSomething() {
int age = 25
//age = "youthful" // ERROR: cannot cast 'youthful' to an Integer
println "Age: ${age}"
}
doSomething() // call it
// do same at outer level
int age = 25
age = "youthful" // OK: dynamic typing permitted here
println "Age: ${age}"
Issue Links
| This issue is depended upon by: | ||||
| GROOVY-761 | static typing |
|
|
|
the reason for this bug was, that the varibale was stored in the binding, rather than creating a lokal variable. This is now changed and so this will throw an Exception too