-
Notifications
You must be signed in to change notification settings - Fork 328
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
Treat null as undefined #86
Comments
@felixfbecker we do treat undefined and null 'equal' in the protocol.I even think that I state somewhere that you should send null not undefined since undefined doesn't exist in other languages. On our server side we even have code that explicitly exchanges undefined with null. And the client code always treats undefined and null as 'equal' However in the case you pointed out I explicitly tried to followed the JSON RPC spec which states:
Would it be possible for your php json library to have two type of Response. FailedResponse and SuccessResponse. |
Good to know you keep it in mind :) |
JavaScript is very special with the seperation between
null
andundefined
. In many other languages such as PHP, if a property has not been set, it isnull
. Consequently, not-set properties will also JSON-encode tonull
. There is no way to find out if a property isnull
because it has been set tonull
or because the property was not set.My PHP language server responds with this response to the
initialize
request:For a human reading this, it is clear that the request was successful,
result
is defined anderror
is not defined. But the language client explicitely checks iferror !== undefined
here. This makes VS Code treat the request as a failed, and then fail withCannot read property 'code' of null
, because it tries to read thecode
property of the error.It makes it impossible to implement the language server protocol with classes in any language that does not have a dedicated
undefined
type. Please just treatnull
asundefined
.value != undefined
will betrue
for bothnull
andundefined
.The text was updated successfully, but these errors were encountered: