-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix case where loopvar is redefined with an explicit i := i define (p…
…re 1.22 fix for loopvar) with the same name as the original. all the other tests were using a new variable name, so we missed this case.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
func main() { | ||
foos := []func(){} | ||
|
||
for i := 0; i < 3; i++ { | ||
i := i | ||
foos = append(foos, func() { println(i) }) | ||
} | ||
foos[0]() | ||
foos[1]() | ||
foos[2]() | ||
} | ||
|
||
// Output: | ||
// 0 | ||
// 1 | ||
// 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
func main() { | ||
foos := []func(){} | ||
|
||
for i := range 3 { | ||
i := i | ||
foos = append(foos, func() { println(i) }) | ||
} | ||
foos[0]() | ||
foos[1]() | ||
foos[2]() | ||
} | ||
|
||
// Output: | ||
// 0 | ||
// 1 | ||
// 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters