-
Notifications
You must be signed in to change notification settings - Fork 131
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
Clarify range of number #422
Comments
Slightly related - is it acceptable for scientific notation to be used for integers even when there is not precision loss? For example can a DAP client/server send Right now, the Dart adapter will throw given scientific notation because Dart deserialises scientific notation to Unfortunately I haven't been able to find anything concrete online and since servers and clients need to agree, perhaps it's worth stating something in the DAP spec. |
I also just realised that the json spec says |
The JSON schema is the normative definition of DAP. The TypeScript types are shown in the markdown for digestibility, and JAvaScript/TypeScript does not have an integer type, so they're shown as a The note about bounds is manually added in the comments of many DAP types. We could declare, in the overview, that integer types should fit in an int32, and then adjust the generator such that the note about range is automatically added on integer-typed fields in the markdown. We can also advise that clients represent the number in standard notation. We should go through and see what integer types should not be int32's, for example the |
If that's the case it may be worth rephrasing "A machine-readable JSON schema can be found here." at the top of the specification page. It sounds more like an extra, and doesn't highlight that it's in fact the source of truth.
I think that's why the LSP specification declares a type alias for integer, uinteger and decimal. Couldn't the DAP specification do the same? |
This seems to be noted here, although it uses the word may:
I think this should be concrete. "may" should be removed and if there are locations where they are allowed to be more than 32 bit, they should use a different type (
I think this should be specified rather than advised (whether scientific notation is allowed or not). For good interoperability I think it's import the rules are absolutely clear. |
This relates a bit to #90
The specification uses
number
pretty much everywhere. For example:But it doesn't define
number
.In some languages
number
refers to either a float or integer.The JSON schema uses
integer
in the same place. But also doesn't define a minimum or maximum. (As far as I could find, JSON schema doesn't define a limit forinteger
either, it would have to be set viamaximum
)There are a few places where the length is explicitly pointed out:
number
without any upper bound is problematic because languages/libraries can choose to serialize them differently:Concrete example:
mfussenegger/nvim-dap#1004
The cjson library in Neovim converts largish numbers to scientific notation, leading to precision loss:
This behavior is within the JSON specification but currently breaks the dart debug adapter.
Could the specification clarify the allowed range of numbers and also clarify to which precision it must serialize them without falling back to scientific notation?
Maybe similar to the LSP spec:
The text was updated successfully, but these errors were encountered: