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: empty hover response should be null, not a zero struct #37570

Closed
zikaeroh opened this issue Feb 28, 2020 · 6 comments
Closed

x/tools/gopls: empty hover response should be null, not a zero struct #37570

zikaeroh opened this issue Feb 28, 2020 · 6 comments
Assignees
Labels
Milestone

Comments

@zikaeroh
Copy link
Contributor

@zikaeroh zikaeroh commented Feb 28, 2020

Please answer these questions before submitting your issue. Thanks!

What did you do?

Hovered over a keyword, like package or func.

What did you expect to see?

No hover, as it's not really helpful.

What did you see instead?

No hover, but my client (VS Code) reports that the markup content kind is unsupported.

image

The logs for the hover above say:

Trace - 10:30:51.946 AM] Sending request 'textDocument/hover - (5)'.
Params: {"textDocument":{"uri":"file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/repeat.go"},"position":{"line":0,"character":3}}


[Trace - 10:30:51.949 AM] Received response 'textDocument/hover - (5)' in 3ms.
Result: {"contents":{"kind":"","value":""},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}}

So gopls is sending a zero'd hover response rather than nil/null. There might be other conditions where a zero hover is returned, but hovering over a keyword is the easiest method to reproduce this.

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.1.8-0.20200228194328-a628ca32ebc0 h1:/+Nv8+K3X0WFGQqkDtuQYvf1VoDYtKkFw6hBGjwyunk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20200228194328-a628ca32ebc0 h1:bC/KxYpsTCppyXiguiVppCnZLkQpMNIi042/S5bYanA=
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.14 linux/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOENV="/home/jake/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jake/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jake/zikaeroh/hortbot/hortbot/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build561120271=/tmp/go-build -gno-record-gcc-switches"
@gopherbot gopherbot added this to the Unreleased milestone Feb 28, 2020
@gopherbot gopherbot added the Tools label Feb 28, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 28, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls label Feb 28, 2020
@zikaeroh
Copy link
Contributor Author

@zikaeroh zikaeroh commented Feb 29, 2020

Aha, so this only happens when I've set -remote=auto. Many hovers appear to do this, especially when the file has syntax errors and you're hovering over them.

cc @findleyr

@findleyr
Copy link
Contributor

@findleyr findleyr commented Mar 2, 2020

Thanks for the report!

Just so I understand: is the problem just the hover serialization, or are you also not getting hover results when you'd expect them?

@findleyr findleyr self-assigned this Mar 2, 2020
@zikaeroh
Copy link
Contributor Author

@zikaeroh zikaeroh commented Mar 2, 2020

I believe it's only under cases where gopls would have been sending a nil hover. Other hovers are fine. It just seems like nil hovers are being converted to empty on forward.

@findleyr
Copy link
Contributor

@findleyr findleyr commented Mar 2, 2020

Thanks, that seems like a perfectly plausible bug -- I'll look into it.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Mar 2, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 4, 2020

Change https://golang.org/cl/222058 mentions this issue: internal/lsp/protocol: unmarshal to pointers when dispatching requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.