x/tools/gopls: with Go 1.17, certain invalid packages fail to re-import. #59179
Labels
FrozenDueToAge
gopls/incremental
gopls
Issues related to the Go language server, gopls.
okay-after-beta1
Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1
release-blocker
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
As we work on making gopls incremental in #57987, we rely heavily on being able to export and then re-import both valid and invalid types.Packages.
I have just encountered the first instance where this fails, but only with Go 1.17:
The following code is invalid at 1.17, but valid at 1.18:
(on 1.18, B is a valid constraint interface).
Go 1.17 contained much code supporting generics behind the scenes in go/types, and so reports an error at the embedding of A, but does not record the embedded type as Typ[Invalid]. Then importing fails here:
https://cs.opensource.google/go/go/+/refs/tags/go1.17.9:src/go/types/type.go;l=574;drc=66007e5cfc9e151485791d440b7e67d44af1b29f
This is an unfortunate instance where Go 1.17 is long since not supported by the Go project, but still supported by gopls until at least Go 1.21 comes out. I think it suffices for us to let the import fail, but we need to make sure we produce accurate diagnostics for this code at Go 1.17, and get reasonable behavior in importing packages.
CC @adonovan
The text was updated successfully, but these errors were encountered: