-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: redundant typecheck errors when using map[T]func(Undefined) #36039
Comments
/cc @griesemer |
I also didn't check what go/types does here. It's probably worth seeing if both typecheckers do the right thing when one uses undefined names inside common combinations of types (map+slice, func+map, slice+pointer, etc). |
Simpler repro:
Yields two errors. Contrast with:
which yields one. |
Arguably, two errors here is correct: the name "Undefined" is not defined, which makes it bad. But the assignment of a pointer-to-function type to an integer is also an error, since that's wrong no matter what Undefined resolves to. However, whether we emit one or two errors, we should probably be consistent between |
What commit you use? On current tip 7d30af8:
yields two errors. |
Oh, go1.13.5 yields one error only. |
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
https://play.golang.org/p/PYwYgOfQo5S
What did you expect to see?
Three simple errors, just saying that
Undefined
is undefined on each of the three lines.What did you see instead?
A redundant error on the
map[...]func(...)
line:It distracted me in some real code, particularly because the shorter and more helpful error is below it. We probably want all three cases to error in a consistent way.
The text was updated successfully, but these errors were encountered: