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: metadata is not invalidated by fixing import syntax #52981

Closed
findleyr opened this issue May 18, 2022 · 1 comment
Closed

x/tools/gopls: metadata is not invalidated by fixing import syntax #52981

findleyr opened this issue May 18, 2022 · 1 comment
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

Comments

@findleyr
Copy link
Contributor

Gopls does not re-evaluate metadata when an import declaration goes from invalid to valid. For example, if I type the following:

import (
  _ "embed"

and then type the closing ), to get to this:

import (
  _ "embed"
)

I will get the error "could not import embed (no required module provides package "embed"). This error is misleading: of course std 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

@findleyr findleyr added the gopls/metadata Issues related to metadata loading in gopls label May 18, 2022
@findleyr findleyr added this to the gopls/v0.9.0 milestone May 18, 2022
@findleyr findleyr self-assigned this May 18, 2022
@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 May 18, 2022
@gopherbot
Copy link

Change https://go.dev/cl/407501 mentions this issue: internal/lsp/cache: invalidate metadata when parsing issues resolve

@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Projects
None yet
Development

No branches or pull requests

2 participants