-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
go/types: interface mismatch error message could be more helpful #54942
Comments
The rust compiler's output is:
|
/cc @griesemer @findleyr |
I think the diff would be more obvious if the parameter names are omitted:
|
@afq984 agreed. When printing the method signatures, they should both be printed the same way, without parameter names. This would reduce clutter and show the difference right away. There's more that could be done, but this is an easy an effective fix. I will take care of this. |
Change https://go.dev/cl/430416 mentions this issue: |
FWIW, I think we should consider doing better here. Compare #54258: I think that it would be useful if the type-checker could report a specific reason why two types are not identical. |
What version of Go are you using (
go version
)?1.19
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?All
What did you do?
Tried to compile slightly incorrect code.
A staged reproduction of a real case can be seen at https://go.dev/play/p/wU5P93xIA2Q
What did you expect to see?
An error message that helped me identify the specific issue immediately.
In particular, the real world scenario involved some folks used to Rust, and they found it
annoying to have to manually diff the involved arguments when the compiler knew exactly which one
was wrong, and they knew in Rust the specific issue would be clearly highlighted and thus immediately obvious.
Here's an attempted Rust transliteration that shows the error message: https://godbolt.org/z/ncv67o93M
What did you see instead?
An adequate but less helpful than it could be error message.
Go types are generally simpler so there's less need for compiler help (maybe more now with generics), but in cases where the compiler knows exactly which of the 7 or so involved types is wrong by one character, it'd be neat if it could expose that information.
The text was updated successfully, but these errors were encountered: