Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wrong type for protocol #266

Closed
NamPNQ opened this issue Dec 10, 2024 · 3 comments
Closed

Wrong type for protocol #266

NamPNQ opened this issue Dec 10, 2024 · 3 comments

Comments

@NamPNQ
Copy link
Contributor

NamPNQ commented Dec 10, 2024

Follow the spec in here: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#uinteger

uinteger: Defines an unsigned integer number in the range of 0 to 2^31 - 1

Do we do the wrong type for uinterger, it should be uint32?

https://github.com/nim-lang/langserver/blob/master/protocol/types.nim#L12

As a result, we encounter failures when executing the command format, as shown here: https://github.com/nim-lang/langserver/blob/master/routes.nim#L700

We are using int.high, and in the case of a 64-bit system (which is common on most computers today), this will lead to an overflow, causing some language clients to fail.

For example, in Zed, I received the following log:

Caused by:
    0: failed to deserialize response
    1: invalid value: integer `9223372036854775807`, expected u32 at line 1 column 77
[2024-12-10T16:00:34+01:00 ERROR lsp] failed to deserialize response from language server: invalid value: integer `9223372036854775807`, expected u32 at line 1 column 77.
@jmgomez
Copy link
Collaborator

jmgomez commented Dec 10, 2024

Good catch. Not sure why its using int but feel free to make a PR :)

@NamPNQ
Copy link
Contributor Author

NamPNQ commented Dec 10, 2024

I just created the PR to fix format fail #267, instead of deal with a lot of changes by change type in protocol

@jmgomez jmgomez closed this as completed Dec 19, 2024
@NamPNQ
Copy link
Contributor Author

NamPNQ commented Dec 19, 2024

I think we should update it, or just keep like that?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants