x/tools/gopls: metadata is not invalidated by fixing import syntax #52981
Labels
FrozenDueToAge
gopls/metadata
Issues related to metadata loading in gopls
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Gopls does not re-evaluate metadata when an import declaration goes from invalid to valid. For example, if I type the following:
and then type the closing
)
, to get to this:I will get the error
"could not import embed (no required module provides package "embed")
. This error is misleading: of coursestd
provides embed, but gopls assumes the validity of its pre-computed package graph for its importer. In this case, the problem is that before the import statement was parseable,go list
did not return the "embed" dependency, and when it becomes parseable we do not invalidate metadata and re-run go list. Typing within an import spec resolves the problem (e.g. deleting and re-typing "d").Clearly our heuristic for detecting import changes is wrong.
CC @adonovan
The text was updated successfully, but these errors were encountered: