mirror of
https://github.com/golang/go
synced 2024-10-04 15:09:59 +00:00
cmd/gc: silence assignment errors to undefined symbols
Fixes #6406. R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/46900043
This commit is contained in:
parent
880442f110
commit
f2e94b58a0
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
12
test/fixedbugs/issue6406.go
Normal file
12
test/fixedbugs/issue6406.go
Normal file
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue