Skip to content
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: field lookup failure message too hard to read #26234

Closed
rsc opened this issue Jul 5, 2018 · 1 comment
Closed

go/types: field lookup failure message too hard to read #26234

rsc opened this issue Jul 5, 2018 · 1 comment
Assignees
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Jul 5, 2018

Compare the messages from the gc compiler and go/types (via vet):

$ go test -run=GetMod
# golang.org/x/vgo/vendor/cmd/go/internal/work
internal/work/build.go:463:70: p.Main undefined (type *load.Package has no field or method Main)
# golang.org/x/vgo/vendor/cmd/go/internal/work
internal/work/build.go:463:71: invalid operation: p (variable of type *golang.org/x/vgo/vendor/cmd/go/internal/load.Package) has no field or method Main
vet: typecheck failures
FAIL	golang.org/x/vgo/vendor/cmd/go [build failed]
$

("go test" should not be showing both, but that's a different issue.)

The vet message looks like "invalid operation: p (side note)" and made me wonder "how is p an operation?" It took me a while to notice there was more text after the parenthetical that continued the original message. I think the gc message is much clearer here, and go/types should switch to it:

p.Main undefined (type *load.Package has no field or method Main)

or at least:

invalid operation: p.Main (type *load.Package has no field or method Main)

Shortening "golang.org/x/vgo/vendor/cmd/go/internal/load" to "load" also dramatically improves the usability and should probably be done too.

@rsc rsc added this to the Go1.12 milestone Jul 5, 2018
@griesemer griesemer self-assigned this Dec 6, 2018
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 6, 2018

Change https://golang.org/cl/152764 mentions this issue: go/types: better error messages for field lookup errors

Loading

@gopherbot gopherbot closed this in 9e0ec5e Dec 6, 2018
@golang golang locked and limited conversation to collaborators Dec 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants