mirror of
https://github.com/golang/go
synced 2025-06-12 17:11:51 +00:00
cmd/gc: fix parallel assignment in range
for expr1, expr2 = range slice was assigning to expr1 and expr2 in sequence instead of in parallel. Now it assigns in parallel, as it should. This matters for things like for i, x[i] = range slice. Fixes #3464. R=ken2 CC=golang-dev https://golang.org/cl/6252048
This commit is contained in:
@ -58,6 +58,17 @@ func testslice() {
|
||||
println("wrong sum ranging over makeslice")
|
||||
panic("fail")
|
||||
}
|
||||
|
||||
x := []int{10, 20}
|
||||
y := []int{99}
|
||||
i := 1
|
||||
for i, x[i] = range y {
|
||||
break
|
||||
}
|
||||
if i != 0 || x[0] != 10 || x[1] != 99 {
|
||||
println("wrong parallel assignment", i, x[0], x[1])
|
||||
panic("fail")
|
||||
}
|
||||
}
|
||||
|
||||
func testslice1() {
|
||||
|
Reference in New Issue
Block a user