-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: semanticTokensProvider response uses nulls incorrectly #59479
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
Comments
Thanks for the bug report. I'll try to fix it. (I presume the client in SemanticTokensClientCapabilities is not sending any tokenTypes.) |
Out of curiosity, are there any checks that the JSON encoded by gopls adheres to the LSP spec, perhaps if they publish a JSONSchema? Presumably that sort of check or static analysis could have caught this bug, and there might be other similar bugs lurking. I only found this one because Helix's decoder for LSP types appears to be fairly strict, whereas Neovim's appears to be more forgiving. |
They do publish a JSON schema, and the Go code is derived from it. But
the translation from LSP types (which are Typescript types) into Go types
is not straightforward. For instance, Go structs do not have optional
fields, nor does Go have union types. Further, and relevant to this bug, x
in
var x struct {
A []string
}
is serialized as '{"A": null}' so the error is not a type error in the Go
code. Fortunately the error can be fixed with x.A = make([]string,0), and
then x serializes as `{"A": []}`
I would be delighted to learn of some sort of analysis, static or
otherwise, that would have found this bug.
…On Fri, Apr 7, 2023 at 12:48 PM Daniel Martí ***@***.***> wrote:
Out of curiosity, are there any checks that the JSON encoded by gopls
adheres to the LSP spec, perhaps if they publish a JSONSchema? Presumably
that sort of check or static analysis could have caught this bug, and there
might be other similar bugs lurking. I only found this one because Helix's
decoder for LSP types appears to be fairly strict, whereas Neovim's appears
to be more forgiving.
—
Reply to this email directly, view it on GitHub
<#59479 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJIAIYF4RFIAOCMNSKIAUTXABAN7ANCNFSM6AAAAAAWWRJNF4>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
Interesting, thanks for the context. You might like to hear that with @dsnet and others we've been looking at a new encoding/json design, and it no longer encodes nil slices as So that would at least solve this one quirk. With optional fields, could you not use pointers and With union/sum types, I agree that that's simply a limitation of the Go type system. You could potentially still do something involving interfaces and unexported methods, like |
Change https://go.dev/cl/483216 mentions this issue: |
Confirming that the integration with Helix is fixed :) |
What did you do?
Trying a new editor, https://helix-editor.com/, which has built-in support for LSPs like gopls.
I'm using gopls master, just like I usually do with neovim.
What did you expect to see?
It should work out of the box, just like it does with neovim's native lsp support. In fact, I had tried a previous release of Helix with a previous version of gopls and they did work together, so this breakage is new.
What did you see instead?
Helix apparently does not connect to gopls properly. I ended up filing a helix bug at helix-editor/helix#6545, although they seem to have spotted a bug in gopls instead.
I am quoting the relevant comment for reference:
Build info
The text was updated successfully, but these errors were encountered: