Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: better error message for scoped type error #15575
I think there should be a better error message for this case, as debugging it was super hard.
It's not a common mistake: local types are rare, and local types named like outer types are even more rare, so I'd say there's no urgency on this.
That said, if we just say something like "type T (defined in F)" we could provide a very accurate message. Shouldn't be hard to do. It's a bit of a balance between precision of error and overly verbose error message.
CL 42750 adds support for line number disambiguation when using two different-but-identical-looking named types, but there are also cases where we have different-but-identical-looking anonymous types. For example:
And in general, there might be arbitrarily many different named types within the source and destination types (e.g., maps and structs)
Are we happy to only special case named types? Or any ideas how to explain to the user why "map[K]V" and "map[K]V" might be different types?