-
Notifications
You must be signed in to change notification settings - Fork 86
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
Do not use u64 for numbers that could be negative #84
Comments
That seems like a mistake in this crate. Do you know of any other fields where this could be an issue? PRs appreciated! |
This is the only field I have seen failing in my case, but it could be nice to do a general review of all the uses of "Be tolerant in what you receive and conservative in what you send" as they say. |
The typescript type This library generally uses
|
@hannni Thanks for looking into this!
These refer to JSON-RPC request ids so they will always be an integer at least but it does seem like they can technically be negative. As each request should have a unique id there probably every implementation will start at 0 and increment the counter from there. Wouldn't hurt to use i64 but it is unlikely to cause issues.
In this case,
Same deal as with I'd be happy to accept a PR for any issues but they do seem rather implausible.
Well, that can also cause incompatibilities between different implementations as these ambigous cases get treated differently. |
I may sound a bit hesitant against changes in the above comment. That is just because the crate is meant to give users of the crate as many assurances about the values they get as possible. Expanding a field to allow both positive and negative numbers drops one such assurance so even while it can be technically correct, it may not be necessary in practice and thus be a bit of a pessimisation. |
I ran into this issue using "kak-lsp" with an internal LSP server that uses While I appreciate that the goal of this crate is to provide type guarantees, the LSP spec documentation says this about the
(https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp) That means an implementor is free to return Adding @ul to provide a better solution for kak-lsp if I am missing something here. |
@vnagarnaik I'd be happy to accept a PR for changing |
Created pull request for updating SignatureHelp types: #100 |
The plugin LSP Support for Jetbrains IDE's uses -1 as the first version for text document :( |
Hello,
It seems various fields specified as "number" in the lsp spec are set as u64 in the library, for example
SignatureHelp::activeParameter
. While it seems to make sense, there is no guarantees language servers wont send a negative value there, and in particular eclipse.jdt.ls seems to send-1
in some cases for this, leading to deserialization failures.I think u64 should only be used for fields that are guaranteed by the lsp standard to be always >= 0, such as positions.
The text was updated successfully, but these errors were encountered: