Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: misleading error message for index expression #49571

mdevan opened this issue Nov 13, 2021 · 1 comment

cmd/compile: misleading error message for index expression #49571

mdevan opened this issue Nov 13, 2021 · 1 comment


Copy link

@mdevan mdevan commented Nov 13, 2021

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?


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 {

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.

What did you expect to see?

Only the second error message (undefined: c).

What did you see instead?

As shown above.

Copy link

@odeke-em odeke-em commented Nov 13, 2021

Thank you @mdevan for reporting this issue! It is fixed for Go1.18 thanks be to the excellent work that @findleyr and @griesemer implemented this cycle.

$ go version && go run main.go 
go version devel go1.18-5344dcae41 Tue Nov 9 00:08:42 2021 +0000 darwin/amd64
# command-line-arguments
./main.go:8:13: undefined: c

You can experiment with the latest Go version by following

$ go install
$ gotip download

I shall therefore close this issue, but please don't hesitate to reach out and file more bugs as you see them.

@odeke-em odeke-em added this to the Go1.18 milestone Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants