What version of Go are you using (go version)?
$ go version
go version go1.17.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
What did you do?
In this code:
if a, b := c["foo"]; b {
fmt.Print(a)
}
if the variable 'c' is not defined, these errors are reported:
./prog.go:8:10: assignment mismatch: 2 variables but 1 value
./prog.go:8:13: undefined: c
The first error message is misleading and redundant.
https://play.golang.org/p/I0TcR8834tK
What did you expect to see?
Only the second error message (undefined: c).
What did you see instead?
As shown above.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
In this code:
if the variable 'c' is not defined, these errors are reported:
The first error message is misleading and redundant.
https://play.golang.org/p/I0TcR8834tK
What did you expect to see?
Only the second error message (
undefined: c).What did you see instead?
As shown above.