]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/gc: silence assignment errors to undefined symbols
authorDaniel Morsing <daniel.morsing@gmail.com>
Fri, 3 Jan 2014 20:03:20 +0000 (21:03 +0100)
committerDaniel Morsing <daniel.morsing@gmail.com>
Fri, 3 Jan 2014 20:03:20 +0000 (21:03 +0100)
Fixes #6406.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46900043

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

index 31a2f2c5cb207b2dbdccd503a96f63b068c5790d..6f8b6adbbf97eea27608da04f0ec1119dbf7b651 100644 (file)
@@ -2680,6 +2680,11 @@ checkassign(Node *n)
                n->etype = 1;
                return;
        }
+
+       // have already complained about n being undefined
+       if(n->op == ONONAME)
+               return;
+
        yyerror("cannot assign to %N", n);
 }
 
diff --git a/test/fixedbugs/issue6406.go b/test/fixedbugs/issue6406.go
new file mode 100644 (file)
index 0000000..5491193
--- /dev/null
@@ -0,0 +1,12 @@
+// errorcheck
+
+// Copyright 2014 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
+
+func main() {
+       s = "bob" // ERROR "undefined.*s"
+       _ = s // ERROR "undefined.*s"
+}
index a2ad91ff4c371eb176553dbc8938a46b3a4bfb4b..6f1204289a984a9e97a94a78ffe0050685c58013 100644 (file)
@@ -14,5 +14,5 @@ func mine(int b) int {        // ERROR "undefined.*b"
 
 func main() {
        mine()          // GCCGO_ERROR "not enough arguments"
-       c = mine()      // ERROR "undefined.*c|not enough arguments" "cannot assign to c"
+       c = mine()      // ERROR "undefined.*c|not enough arguments"
 }