aboutsummaryrefslogtreecommitdiff
path: root/test/range.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-05-24 23:05:36 -0400
committerRuss Cox <rsc@golang.org>2012-05-24 23:05:36 -0400
commit51072eb1fb2c380284cd0f87e61d1589201c3eea (patch)
tree12867624528dcbdac61ba1af36ae029f794c510f /test/range.go
parentbf18d57d4a186302ed7a3b07d60cd6facda08a71 (diff)
downloadgo-51072eb1fb2c380284cd0f87e61d1589201c3eea.tar.gz
go-51072eb1fb2c380284cd0f87e61d1589201c3eea.zip
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
Diffstat (limited to 'test/range.go')
-rw-r--r--test/range.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/range.go b/test/range.go
index b0f3ae605a..68b0c9a2f3 100644
--- a/test/range.go
+++ b/test/range.go
@@ -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() {