cmd/compile: confusing assignment mismatch error when indexing map with invalid key #50762
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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 env
OutputWhat did you do?
Compiling this invalid program: https://play.golang.com/p/QWTPYt1MIep
... yields the following error:
While the second error is completely reasonable, and probably what I would expect to see first and foremost, the first error is rather confusing. When fixing compile errors with a lot more messages, and getting a bit tunnel-visioned on fixing them one after the other, I was left wondering what was wrong with my program and attempting to change some variable names in hope of fixing it, only to realize a couple of minutes later that the undefined key was the actual issue.
This is of course pretty minor, but I wish the compiler hadn't shown me the first error since it threw me for a loop.
The text was updated successfully, but these errors were encountered: