-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
x/tools/go/packages: confusing error when loading source newer than toolchain used to build application #55883
Comments
Change https://go.dev/cl/435356 mentions this issue: |
It seems strange to issue a warning without knowing what the caller is going to do with the results of the call. What if they only want to list the files? Returning a hard error if |
Yes, the same thought occurred to me, though I'm still not sure a hard error is warranted. What if someone updated their go toolchain but is still only using it to build older code? It seems rough that they would have to rebuild any apps that use go/packages. Perhaps we should continue to issue a warning but only if the parser is used. (The problem is broader than NeedTypes.) Or even defer the version check until parsing or type checking fails, and append it to the parse/type errors? |
When an application that links go/packages is built with a go1.18 toolchain, it includes go1.18's type checker (go/types). If the application is then used with version go1.20 of the go command on the PATH, go list will report source files that may rely on language features of go1.20 (such as recent additions to the unsafe package), which aren't supported by its type checker. The errors are confusing; see #55045.
Instead, go/packages should either instruct go list to select files using release tags corresponding to the version of the type checker linked with it, or should otherwise detect and report the version skew in a straightforward message.
See also:
The text was updated successfully, but these errors were encountered: