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/gopls: handle go1.22's go/types.Alias #64581

Open
adonovan opened this issue Dec 6, 2023 · 2 comments
Open

x/tools/gopls: handle go1.22's go/types.Alias #64581

adonovan opened this issue Dec 6, 2023 · 2 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Dec 6, 2023

This issue tracks the adoption in gopls of go1.22's new types.Alias type. We will need to audit every place that type-switches or type-asserts a types.Type to ensure that it works correctly with the new type. Initially the type checker will not produce instances of these types unless GODEBUG=gotypesalias=1 is set.

Things to resolve:

  • go/types: Alias.String should not mention the aliased type #64584 (done)
  • waiting for cmd/compile support for writing aliases
  • gcimporter support for reading and writing aliases (see attached CL)
  • sprinkling Unalias in a great many places (see attached CL)
  • supporting parameterized aliases (for now my goal is just to support with the new representation of simple aliases).
  • adding tests to each x/tools package with aliases, both ordinary and parameterized.
  • working with @dominikh to upgrade staticcheck in a similar way.
  • working with the vulncheck folks to do the same.

@gri @findleyr

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 6, 2023
@gopherbot gopherbot added this to the Unreleased milestone Dec 6, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.16.0 Dec 6, 2023
@gopherbot
Copy link

Change https://go.dev/cl/547876 mentions this issue: gopls: updates for go1.22 types.Alias

@adonovan
Copy link
Member Author

adonovan commented Dec 7, 2023

I tested gopls using tip GOROOT after hardwiring types.Checker.enablealias to true. (We can't use GODEBUG=gotypesalias=1 to control it yet because this environment variable would be inherited by 'go list' and the Go compiler, which doesn't yet have support for writing out Alias types, so it crashes.)

I added rudimentary support to the gcimporter package used by gopls for reading and writing aliases, and sprinkled lots of Unalias operations throughout the tree, and was able to get all but three tests (of vulncheck and staticheck) to pass. So I think it's in good shape for the 1.22 release, though we have a lot of work to do after the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. 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