x/tools/gopls: race in ad-hoc package reloading can lead to conflicting diagnostics #57209
Labels
FrozenDueToAge
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 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:
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 loadfile:b.go
before reloading the directory.
, resulting in multiple packages containingb.go
, one of which does not containa.go
.CC @adonovan
The text was updated successfully, but these errors were encountered: