summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/sinit.c6
-rw-r--r--test/fixedbugs/bug227.go34
2 files changed, 40 insertions, 0 deletions
diff --git a/src/cmd/gc/sinit.c b/src/cmd/gc/sinit.c
index ade8426c0..b1160d3d4 100644
--- a/src/cmd/gc/sinit.c
+++ b/src/cmd/gc/sinit.c
@@ -94,6 +94,12 @@ init1(Node *n, NodeList **out)
init1(l->n, out);
*out = list(*out, n->defn);
break;
+
+ case OAS2MAPR:
+ for(l=n->defn->rlist; l; l=l->next)
+ init1(l->n, out);
+ *out = list(*out, n->defn);
+ break;
}
}
l = initlist;
diff --git a/test/fixedbugs/bug227.go b/test/fixedbugs/bug227.go
new file mode 100644
index 000000000..be27a68ce
--- /dev/null
+++ b/test/fixedbugs/bug227.go
@@ -0,0 +1,34 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var (
+ nf int
+ x, y, z = f(), f(), f()
+ m = map[string]string{"a":"A"}
+ a, aok = m["a"]
+ b, bok = m["b"]
+)
+
+func look(s string) (string, bool) {
+ x, ok := m[s]
+ return x, ok
+}
+
+func f() int {
+ nf++
+ return nf
+}
+
+func main() {
+ if nf != 3 || x != 1 || y != 2 || z != 3 {
+ panic("nf=", nf, " x=", x, " y=", y)
+ }
+ if a != "A" || aok != true || b != "" || bok != false {
+ panic("a=", a, " aok=", aok, " b=", b, " bok=", bok)
+ }
+}