cmd/vet: throwing "refers to unknown identifier" error depending on file loading order #29570
Labels
Comments
I can reproduce the problem with Go 1.11, but it is fixed on tip. |
I too fail to reproduce this on tip (1.12). Vet has been heavily refactored in this cycle, so I'm assuming that the fix was part of that and would be very hard to backport. /cc @alandonovan @ianthehat in case they have any ideas about a potential backport. But with 1.12 less than a month away, and given that this is an edge case in vet, I don't think it's worth the effort. |
I don't think this warrants a backport. Closing. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I received an error from
go vet
when attempting to validate a custom errors package. It appears that there is a file loading order race condition with the custom package and the standard errors package.I have created a repository with code that reproduces the issue.
https://github.com/bytheway/VetFailure
Essentially,
go vet
will return the errorwhen run bare, but if you feed the files to go vet in a reversed order, it passes.
This is probably related to having 2 files using the errors_test package, one of them also using the stdlib errors package (imported to a goErrors name). If the one importing stdlib errors comes first, go vet is unable to resolve the ExampleFunc() identifiers. If the order is reverse (examples, then the tests w/stdlib errors), then go vet passes.
What did you expect to see?
go vet
should validate that the files are properly formed.What did you see instead?
go vet
detects a spurious error.The text was updated successfully, but these errors were encountered: