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: diagnostics not cleared when import cycle is resolved #46667

Closed
findleyr opened this issue Jun 9, 2021 · 6 comments
Closed

x/tools/gopls: diagnostics not cleared when import cycle is resolved #46667

findleyr opened this issue Jun 9, 2021 · 6 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Jun 9, 2021

Setup:

-- go.mod --
module mod.test

go 1.16
-- a/a.go --
package a

import "mod.test/b"

const A = b.A
const B = 2
-- b/b.go --
package b

import "mod.test/a"

const A = 1
const B = a.B

Deleting const B and saving to run goimports resolves the import cycle, but leaves gopls in a broken state:

  a/a.go:3 [compiler BrokenImport] Error could not import mod.test/b (no required module provides package "mod.test/b")
  b/b.go:1 [go list]  Error import cycle not allowed: import stack: [mod.test/b mod.test/a mod.test/b]

CC @stamblerre

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 9, 2021
@findleyr findleyr added this to the gopls/v0.7.1 milestone Jun 9, 2021
@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 Jun 9, 2021
@kentquirk
Copy link

kentquirk commented Jun 9, 2021

I think #43821 is probably related/identical. It was closed without explicit resolution earlier this year.

@findleyr
Copy link
Contributor Author

findleyr commented Jun 9, 2021

I think #43821 is probably related/identical. It was closed without explicit resolution earlier this year.

Thanks, that does look likely: a go list error becoming sticky. Both are probably related to stale package metadata.

@gopherbot
Copy link

Change https://golang.org/cl/326589 mentions this issue: internal/lsp/cache: invalidate broken packages when imports are deleted

@jurisbu
Copy link

jurisbu commented Jul 27, 2021

So is this going to be fixed? Not clear from above :)

I can easily reproduce it with gopls v0.7.0.

Annoying to have to restart language server each time after fixing code.

@stamblerre
Copy link
Contributor

@jurisbu: The fix will be released this week. But this should only occur when you have an import cycle in your program--which should not happen often.

@jurisbu
Copy link

jurisbu commented Jul 28, 2021

@stamblerre Thanks for update!
I know that this issue appears mostly due to user error, but nevertheless sometimes it just happens especially when completion kicks in and by mistake one uses wrong package though one should not. Humans are not without flaws ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants