mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use more specific error message for assignment mismatch
Show a more specifc error message in the form of "%d variables but %v returns %d values" if an assignment mismatch occurs with a function or method call on the right. Fixes #27595 Change-Id: Ibc97d070662b08f150ac22d686059cf224e012ab Reviewed-on: https://go-review.googlesource.com/135575 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
10aeb672e0
commit
ae9c822f78
3 changed files with 31 additions and 7 deletions
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
package p
|
||||
|
||||
var x int = three() // ERROR "1 variable but 3 values"
|
||||
var x int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
|
||||
|
||||
func f() {
|
||||
var _ int = three() // ERROR "1 variable but 3 values"
|
||||
var a int = three() // ERROR "1 variable but 3 values"
|
||||
a = three() // ERROR "1 variable but 3 values"
|
||||
b := three() // ERROR "1 variable but 3 values"
|
||||
var _ int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
|
||||
var a int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
|
||||
a = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
|
||||
b := three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
|
||||
|
||||
_, _ = a, b
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue