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/cmd/gopls: Error on completion when defining identifiers #30966

Closed
rliebz opened this issue Mar 21, 2019 · 2 comments
Closed

x/tools/cmd/gopls: Error on completion when defining identifiers #30966

rliebz opened this issue Mar 21, 2019 · 2 comments

Comments

@rliebz
Copy link

@rliebz rliebz commented Mar 21, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN="/Users/rliebz/Projects/go/bin"
GOCACHE="/Users/rliebz/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/rliebz/Projects/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/rliebz/.asdf/installs/golang/1.12.1/go"
GOTMPDIR=""
GOTOOLDIR="/Users/rliebz/.asdf/installs/golang/1.12.1/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rliebz/Sandbox/sample/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wb/_ss422w92c78hrs6vf8456_r0000gn/T/go-build163524001=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm currently using neovim / LanguageClient-neovim, although the issue should reproduce in any editor. To reproduce, trigger text completion when defining an identifier.

For example:

package foo

func ba

Trigger completion at the end of the file, after ba.

Alternatively:

package foo

type ba

With similar results for const ba, var ba, etc.

What did you expect to see?

gopls should have no errors and return no completion items. Although gopls will be unable provide suggestions, this is expected since a new identifier is being defined. There is not really any exception or error that has occurred.

This is particularly relevant for clients which attempt to provide completion items automatically, since the client will be regularly requesting completions during identifier definitions.

What did you see instead?

An error with the message "this is a definition, of func ba(func(invalid type))", or "this is a definition, of type ba invalid type", etc.

The error is being returned here: https://github.com/golang/tools/blob/36c10c0a621fb2fede4686e8ae7bb1d900735d53/internal/lsp/source/completion.go#L140

@gopherbot gopherbot added this to the Unreleased milestone Mar 21, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 22, 2019

This issue raises an interesting question, because I'm quite confident that the VSCode LSP integration wouldn't display such errors to the user. Still, the formal LSP spec for the error response says that it should be returned if "an exception happens during the completion request." Ultimately, we need to distinguish between errors that a user should see vs. errors that cause the user to see no results.

@stamblerre stamblerre self-assigned this Mar 22, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 17, 2019

Fixed in https://golang.org/cl/170958.

@stamblerre stamblerre closed this Apr 17, 2019
@golang golang locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.