Skip to content

Commit

Permalink
internal/lsp/protocol: avoid replying with non-nil interface values i…
Browse files Browse the repository at this point in the history
…n case of error

The JSON-RPC 2.0 protocol requires that responses objects
have either a "result" or an "error", but not both.
In Go, this corresponds to a non-nil result interface value or a
non-nil error.

However, the generated wrappers for the LSP protocol were passing
non-nil values for both in case of error, due to passing typed-nil
pointers as (non-nil) interfaces (see
https://go.dev/doc/faq#nil_error).

This change fixes the generator to explicitly pass only one or the
other, and re-runs the generator at the existing commit.

For golang/go#49387
For golang/go#46520

Change-Id: I582b52820bdac15d9f947e8d6c1e9daa70c53e40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/388600
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
Bryan C. Mills committed Apr 13, 2022
1 parent 1f10767 commit b7d7574
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 59 deletions.
27 changes: 21 additions & 6 deletions internal/lsp/protocol/tsclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/lsp/protocol/tsprotocol.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b7d7574

Please sign in to comment.