-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types: improve error message quality for ptr receiver errors (go/types differs from go tool compile) #36336
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
gopls uses the go/types package, not the compiler, to type check. go/types doesn't provide as useful of an error message in this situation. It can probably be improved but would be subject to the Go release cycle (rather than gopls). /cc @griesemer |
This is a The compiler reports: go/types reports: It should not be too hard to make the |
Change https://golang.org/cl/229801 mentions this issue: |
The compiler produces high quality error messages when an interface is implemented by *T, rather than T. This change improves the analogous error messages in go/types, from "missing method X" to "missing method X (X has pointer receiver)". I am open to improving this message further - I didn't copy the compiler error message exactly because, at one of the call sites of (*check).missingMethod, we no longer have access to the name of the interface. Fixes golang#36336 Change-Id: Ic4fc38b13fff9e5d9a69cc750c21e0b0c34d85a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/229801 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
In this particular case
go build
has a vastly better error message, assuming it's not vscode but gopls who is responsible for altering the original compile message.gopls:
original go build compiler message:
The text was updated successfully, but these errors were encountered: