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: race in ad-hoc package reloading can lead to conflicting diagnostics #57209

Open
findleyr opened this issue Dec 9, 2022 · 0 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

@findleyr
Copy link
Contributor

findleyr commented Dec 9, 2022

Gopls has some support for ad-hoc packages, which are packages defined in a directory outside of a module or GOPATH. To support them, it sets GO111MODULE=auto and loads .. However, I observe that gopls also load individual files eagerly, and this can lead to conflicting state.

Consider the following simple ad-hoc package:

--- a.go ---
package foo

const X = 1

--- b.go ---
package foo

const Y = X

If I trigger repeated reloads of b.go (for example, by typing in an import statement in b.go), I can sometimes trigger a state where I can an "undefined name: X" diagnostics even though cross references on X work. The reason for this, I assume, is that we eagerly load file:b.go before reloading the directory ., resulting in multiple packages containing b.go, one of which does not contain a.go.

CC @adonovan

@findleyr findleyr added this to the gopls/v0.12.0 milestone Dec 9, 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 Dec 9, 2022
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

2 participants