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 doesn't update when build tags specification changes #38732

Closed
hyangah opened this issue Apr 28, 2020 · 2 comments
Closed
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.

Comments

@hyangah
Copy link
Contributor

hyangah commented Apr 28, 2020

When removing the build tags from a file to include the file in the build set,
the diagnostics don't update. I am guessing this is probably similar to
other diagnostics related bug reports involving new file creation, but the
repro step is slightly different, I decided to report this.

--- foo/foo.go ---
// +build foo

package foo
var Foo = 1

--- foo/bar.go ---
package foo
var Bar = Foo

Gopls will report the reference to Foo from bar.go is undefined.

Now remove the build tag // +build foo from the foo/foo.go and save the file.
Diagnostics on bar.go remain unchanged. Editing/saving bar.go will not change stale diagnostics/symbol info either.

Used go1.14.1, gopls built from master (e9a00ec)
Gopls log is:


[Info - 3:43:19 PM] 2020/04/28 15:43:19
message="Build info\n----------\ngolang.org/x/tools/gopls master\n golang.org/x/tools/gopls@(devel)\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=\n golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=\n golang.org/x/tools@v0.0.0-20191130070609-6e064ea0cf2d => ../\n golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\n honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=\n mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=\n\nGo info\n-------\ngo version go1.14.1 darwin/amd64\n\n"
[Info - 3:43:19 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=0
directory=/Users/hakim/scratch/foo
query=[./... builtin]
packages=2
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go env for /Users/hakim/scratch/foo\n(valid build configuration = true)\n(build flags: [-modfile=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/go.foo.992652678.mod])\nGO111MODULE=""\nGOARCH="amd64"\nGOBIN=""\nGOCACHE="/Users/hakim/Library/Caches/go-build"\nGOENV="/Users/hakim/Library/Application Support/go/env"\nGOEXE=""\nGOFLAGS=""\nGOHOSTARCH="amd64"\nGOHOSTOS="darwin"\nGOINSECURE=""\nGONOPROXY=""\nGONOSUMDB=""\nGOOS="darwin"\nGOPATH="/Users/hakim/go"\nGOPRIVATE=""\nGOPROXY="https://proxy.golang.org,direct\"\nGOROOT=\"/usr/local/go\"\nGOSUMDB=\"sum.golang.org\"\nGOTMPDIR=\"\"\nGOTOOLDIR=\"/usr/local/go/pkg/tool/darwin_amd64\"\nGCCGO=\"gccgo\"\nAR=\"ar\"\nCC=\"clang\"\nCXX=\"clang++\"\nCGO_ENABLED=\"1\"\nGOMOD=\"/Users/hakim/scratch/foo/go.mod\"\nCGO_CFLAGS=\"-g -O2"\nCGO_CPPFLAGS=""\nCGO_CXXFLAGS="-g -O2"\nCGO_FFLAGS="-g -O2"\nCGO_LDFLAGS="-g -O2"\nPKG_CONFIG="pkg-config"\nGOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/go-build444620568=/tmp/go-build -gno-record-gcc-switches -fno-common"\n"
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=1
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Error - 3:43:20 PM] 2020/04/28 15:43:19
message="DocumentSymbols failed"
error=getting file for DocumentSymbols: no PackageHandles
URI=file:///Users/hakim/scratch/foo/foo.go
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=1
package_path="foo"
files=[/Users/hakim/scratch/foo/bar.go]
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=1
directory=/Users/hakim/scratch/foo
query=[foo]
packages=1
[Error - 3:43:20 PM] 2020/04/28 15:43:19
message="failed to compute document links"
error=no PackageHandles
URI=file:///Users/hakim/scratch/foo/foo.go
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=1
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Info - 3:43:20 PM] 2020/04/28 15:43:19
message="go/packages.Load"
snapshot=1
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Info - 3:43:20 PM] 2020/04/28 15:43:20
message="go/packages.Load"
snapshot=1
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Info - 3:43:31 PM] 2020/04/28 15:43:31
message="go/packages.Load"
snapshot=2
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Info - 3:43:31 PM] 2020/04/28 15:43:31
message="go/packages.Load"
snapshot=2
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Info - 3:43:34 PM] 2020/04/28 15:43:34
message="go/packages.Load"
snapshot=2
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Error - 3:43:34 PM] 2020/04/28 15:43:34
message="failed to compute document links"
error=no PackageHandles
URI=file:///Users/hakim/scratch/foo/foo.go
[Info - 3:43:34 PM] 2020/04/28 15:43:34
message="go/packages.Load"
snapshot=2
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=0
[Error - 3:43:34 PM] 2020/04/28 15:43:34
message="DocumentSymbols failed"
error=getting file for DocumentSymbols: no PackageHandles
URI=file:///Users/hakim/scratch/foo/foo.go
[Info - 3:43:51 PM] 2020/04/28 15:43:51
message="go/packages.Load"
snapshot=3
directory=/Users/hakim/scratch/foo
query=[file=/Users/hakim/scratch/foo/foo.go]
packages=1
[Info - 3:43:51 PM] 2020/04/28 15:43:51
message="go/packages.Load"
snapshot=3
package_path="foo"
files=[/Users/hakim/scratch/foo/bar.go /Users/hakim/scratch/foo/foo.go]
[Error - 3:43:52 PM] 2020/04/28 15:43:52
message="DocumentSymbols failed"
error=getting file for DocumentSymbols: no ParseGoHandle for file:///Users/hakim/scratch/foo/foo.go
URI=file:///Users/hakim/scratch/foo/foo.go
[Error - 3:43:55 PM] 2020/04/28 15:43:55
message="DocumentSymbols failed"
error=getting file for DocumentSymbols: no ParseGoHandle for file:///Users/hakim/scratch/foo/foo.go
URI=file:///Users/hakim/scratch/foo/foo.go
[Info - 3:44:01 PM] 2020/04/28 15:44:01
message="background imports cache refresh starting"
[Info - 3:44:01 PM] 2020/04/28 15:44:01
message="background refresh finished after 293.666827ms"

@gopherbot gopherbot added this to the Unreleased milestone Apr 28, 2020
@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 Apr 28, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 28, 2020
@myitcv
Copy link
Member

myitcv commented Apr 29, 2020

Likely related: #37101

@gopherbot
Copy link

Change https://golang.org/cl/296549 mentions this issue: internal/lsp/cache: invalidate metadata on magic comment changes

@stamblerre stamblerre added this to To Do in gopls on-deck Feb 28, 2021
@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Mar 2, 2021
@stamblerre stamblerre moved this from To Do to Done in gopls on-deck Aug 12, 2021
@golang golang locked and limited conversation to collaborators Mar 2, 2022
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

No branches or pull requests

4 participants