-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types: pointer method error less useful than the compiler's #38658
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
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Ah, thanks for reporting! This is another instance of a go/types error differing from a compiler error. I'll try to get a fix in for 1.15. |
Change https://golang.org/cl/230380 mentions this issue: |
The compiler has better error messages for methods called without a pointer receiver when one is expected. This change is similar to CL 229801, but for method calls. Also, added better error messages for functions called with the wrong capitalization. I left the third TODO in this switch statement almost as-is because I'm not sure that the extra complexity is worth it - I adjusted the error to look like the one the compiler reports. Fixes golang#38658 Change-Id: Ie0ca2503e12f3659f112f0135cc27db1b027fdcb Reviewed-on: https://go-review.googlesource.com/c/go/+/230380 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
What did you do?
I was very confused with what was wrong with my code:
Since gopls frequently errors out for whatever reason, I decided to check what
go build
says:The object here is a
zerolog.Logger
(from zerolog), which providesWarn
on a pointer receiver.What did you expect to see?
Compiler error should be same as what
go build
gives.What did you see instead?
Wrong compiler error.
Build info
Go info
The text was updated successfully, but these errors were encountered: