]> Cypherpunks repositories - gostls13.git/commitdiff
gc: remove now redundant typecheck of ->ninit on switches.
authorLuuk van Dijk <lvd@golang.org>
Mon, 9 Jan 2012 20:42:24 +0000 (21:42 +0100)
committerLuuk van Dijk <lvd@golang.org>
Mon, 9 Jan 2012 20:42:24 +0000 (21:42 +0100)
Fixes #2576.

R=rsc
CC=golang-dev
https://golang.org/cl/5498105

src/cmd/gc/swt.c
test/fixedbugs/bug391.go [new file with mode: 0644]

index 7764f0dd3562f8c792de0ca27e9e1b446718dd9d..8b1b93c7dad9e19bc67a44d1db5d4f957206378c 100644 (file)
@@ -792,7 +792,6 @@ walkswitch(Node *sw)
         * cases have OGOTO into statements.
         * both have inserted OBREAK statements
         */
-       walkstmtlist(sw->ninit);
        if(sw->ntest == N) {
                sw->ntest = nodbool(1);
                typecheck(&sw->ntest, Erv);
diff --git a/test/fixedbugs/bug391.go b/test/fixedbugs/bug391.go
new file mode 100644 (file)
index 0000000..8150718
--- /dev/null
@@ -0,0 +1,14 @@
+// $G $D/$F.go || echo "Issue2576"
+
+// Copyright 2011 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.
+
+// Issue 2576
+package bug
+
+type T struct { a int }
+
+func f(t T) {
+        switch _, _ = t.a, t.a; {}
+}
\ No newline at end of file