Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-JSR-4
-
None
-
None
-
Ubuntu Linux, 1.0-JSR-4, on JDK 1.5.0
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.