Open oversoul opened 1 month ago
Thanks for the thorough investigation.
The inclusion of -+*
in TypeErrorEndPos logic was added in https://go.dev/cl/222237; neither the CL description nor any of the test cases reveal why. It would be interesting to instrument go/types to record whenever it produces an error containing one of these symbols, and run its tests (and run it over the standard library) to see what comes up.
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Go version
go1.23.1
Output of
go env
in your module/workspace:What did you do?
Take this example
What did you see happen?
On editor (sublime, neovim), because of the unused import "go.mongodb.org/mongo-driver/bson" it highlights only until the
-
. Usinggopls
commandgopls check api/auth/models.go
the output is:api/auth/models.go:4:2-23: "go.mongodb.org/mongo-driver/bson" imported and not used
23 here is wrong. should be 36.
What did you expect to see?
api/auth/models.go:4:2-36: "go.mongodb.org/mongo-driver/bson" imported and not used
After some research, The issue is in
TypeErrorEndPos
tools/gopls/internal/analysisinternal/analysis.go Line 29
if width := bytes.IndexAny(src[offset:], " \n,():;[]+-*"); width > 0 {
after removing the hyphen, it works as expected. I did run the tests after the change but no tests seems to break.