incorrect output when closure is set in a loop
mvertes opened this issue · comments
Marc Vertes commented
The following program sample.go
triggers an unexpected result
package main
func main() {
var fns []func()
for _, v := range []int{1, 2, 3} {
x := v*100 + v
fns = append(fns, func() { println(x) })
}
for _, fn := range fns {
fn()
}
}
Expected result
$ go run ./sample.go
101
202
303
Got
$ yaegi ./sample.go
303
303
303
Yaegi Version
v0.15.1
Additional Notes
The same issue as in gnolang/gno#1135