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: semanticTokens/range returns a generic error if compilation fails #46176

Closed
leitzler opened this issue May 14, 2021 · 1 comment
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

Comments

@leitzler
Copy link
Contributor

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

$ go version
go version devel go1.17-756e2b1529 Fri Apr 9 19:11:12 2021 +0000 darwin/amd64
$ go list -m golang.org/x/tools golang.org/x/tools/gopls
golang.org/x/tools v0.1.1-0.20210506192834-c0140e85e11c
golang.org/x/tools/gopls v0.0.0-20210506192834-c0140e85e11c

Does this issue reproduce with the latest release?

Yes

What did you do?

Sent a textDocument/semanticTokens/range request with the following source file open:

package main
a
func main() {}
[Trace - 19:57:36.265 PM] Sending request 'textDocument/semanticTokens/range - (8)'.
Params: {"textDocument":{"uri":"file:///private/var/folders/j4/l2j99h6d5qd6knjlllql0bb80000gn/T/tmp.AlyUHk47/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":3,"character":0}}}


[Error - Received] 19:57:36.267 PM #8 /private/var/folders/j4/l2j99h6d5qd6knjlllql0bb80000gn/T/tmp.AlyUHk47/main.go:2:1: expected declaration, found a

What did you expect to see?

Something where the client is able to distinguish "an empty result set" from "failed to deliver a result set".

What did you see instead?

An error (with error code 0 and message containing the compilation error).

From how I understand the LSP specification, the error in a ResponseMessage should include an error code that indicate error type. When I look at the list of codes it looks like most of them is for errors defined by JSON RPC or LSP (such as ContentModified / RequestCancelled). I can't find that using code 0 would be allowed in the specification.

What I cannot do is to let that the client programatically tell the user if an error is (for example) a communication error, bug in the client or "just" the compilation error. Peter had an idea to respond with null (and no error) if gopls couldn't provide a result. That would work for my particular use case, question is how other LSP clients would handle it.

/cc @pjweinb

@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 May 14, 2021
@gopherbot gopherbot added this to the Unreleased milestone May 14, 2021
@gopherbot
Copy link

Change https://golang.org/cl/319249 mentions this issue: internal/lsp: more careful error handling for semantic tokens

@golang golang locked and limited conversation to collaborators May 17, 2022
@rsc rsc unassigned pjweinb Jun 23, 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
None yet
Development

No branches or pull requests

4 participants