summaryrefslogtreecommitdiff
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
commit7e6c626509297af000cea27c981a41d8b614b900 (patch)
treea7e54c7aefcfe3e7198cb87cd267cb6293686bdc /test/range.go
parentac1cd969102d920aecef687b6769a782dd0a85e7 (diff)
downloadgo-7e6c626509297af000cea27c981a41d8b614b900.tar.gz
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 issue 3464. R=ken2 CC=golang-dev http://codereview.appspot.com/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 b0f3ae605..68b0c9a2f 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() {