You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
./example_test.go:7: ExampleDemo refers to unknown identifier: Demo
when 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:
bytheway
changed the title
cmd/vet
cmd/vet throwing "refers to unknown identifier" error depending on file loading order
Jan 4, 2019
ianlancetaylor
changed the title
cmd/vet throwing "refers to unknown identifier" error depending on file loading order
cmd/vet: throwing "refers to unknown identifier" error depending on file loading order
Jan 4, 2019
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.
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: