Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-JSR-4
-
Fix Version/s: 1.0-JSR-5
-
Component/s: None
-
Labels:None
-
Environment:Ubuntu Linux, 1.0-JSR-4, on JDK 1.5.0
-
Number of attachments :
Description
Groovy apparently tries to guess whether you're going to use a loop variable after a for loop ends. There is a bug in the case that you have another for loop that tries to use the same loop variable later. For instance:
for (i in 0..7) {
}
println i
for (i in 0..7) {
}
Groovy produces
loop.groovy: 4: The current scope does already contain a variable of the name i
@ line 4, column 1.
for (i in 0..7) {
^
1 Error
If the println i is commented out, the program runs.
the variable used in the for loop is now local to the for loop ans only visible inside the loop.