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

x/tools/go/packages: confusing error when loading source newer than toolchain used to build application #55883

Closed
adonovan opened this issue Sep 27, 2022 · 3 comments
Assignees
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Sep 27, 2022

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:

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 27, 2022
@gopherbot gopherbot added this to the Unreleased milestone Sep 27, 2022
@adonovan adonovan self-assigned this Sep 27, 2022
@gopherbot
Copy link

Change https://go.dev/cl/435356 mentions this issue: go/packages: warn if 'go list' on PATH is too new

@heschi
Copy link
Contributor

heschi commented Sep 27, 2022

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 NeedTypes is specified makes more sense to me, FWIW.

@adonovan
Copy link
Member Author

adonovan commented Sep 27, 2022

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?

@golang golang locked and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants