LSP integers 0 and 1 serialized to boolean?

Implementing a clangd served, I see that when I put small integers (even if coerced with Number()) into a parameter – the values 0 and 1 when used for ranges (line and column) wind up getting serialized into JSON boolean true/false.

This breaks deserialization in clangd, which means that my extension has no way to utilize the LSP to access symbols on the first line of the file, nor in the first column.

(I also posted something in Get Help about this, but I’ve become more convinced that this is not a misunderstanding on my part but probably a Bug… I’m coming at this relatively new to JavaScript, but note that when I use JSON.stringify() to serialize the parameters they come out as I expect – with numbers rather than booleans, so I conclude it must be something that the Nova internal code is doing wrong. If there is a workaround for this problem, I’d be happy to hear it.)

This is kind of a show stopper for my extension. Panic, help please?

This appears to be due to JavaScriptCore. In converting values from the extension request to native ones, it’s converting Boolean to a number, as Objective-C does not use discrete object types for booleans when placed in collections. We’ll investigate whether this is something that can be improved easily, and if not, file a request to have this code reworked to better preserve booleans in collections.

1 Like

Getting this fixed would be a huge help. There aren’t “easy” workarounds for this.

To be clear, my need is not to preserve booleans (although that’s important too!) but to preserve numbers.

It looks like this is fixed in Nova 10.4. (It was still a bug in 10.3)

Which is just about the best news as I’ve been waiting for a fix for this bug!