Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upJson.Decoder.int Bug / Ints in Elm #337
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 6, 2015
Member
PR #153 was open with a potential fix, but we closed it so @ajhager or @krisajenkins could do a PR with the faster version of the fix.
|
PR #153 was open with a potential fix, but we closed it so @ajhager or @krisajenkins could do a PR with the faster version of the fix. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
And the new PR is on its way. :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
agrafix
commented
Aug 7, 2015
|
Very cool, looking forward to it! :-) @ajhager |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
agrafix
Aug 7, 2015
@evancz what do you think about the behavior of the bitwise module? maybe there should at lease be a warning that is only works for 32 Bits Ints?
agrafix
commented
Aug 7, 2015
|
@evancz what do you think about the behavior of the bitwise module? maybe there should at lease be a warning that is only works for 32 Bits Ints? |
ajhager
referenced this issue
Aug 16, 2015
Merged
Add support for large integers in Json decoder #352
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 22, 2016
Member
Not sure what happened here, so I am going to close. Someone please reopen with fresh information if something else needs to happen.
|
Not sure what happened here, so I am going to close. Someone please reopen with fresh information if something else needs to happen. |
agrafix commentedAug 6, 2015
The javascript spec allows numbers up to 2^53-1 (
9007199254740991) and Elm generally is fine with these large integers, too. The json decoder fails for inputs larger than2147483647.I've found the error in the Native.Json part:
https://github.com/elm-lang/core/blob/2a8dcb522f71541c299a8a465bb39bc17bb9ec67/src/Native/Json.js#L53
It checks that
(value|0) === value, but this check will fail for any input larger than2147483647because binary operators only work on 32bit ints.I did not send a pull request (yet?) because I'm not sure what the correct step is. The Bitwise module allows parameters of type
Int, and this will produce broken results iff the number is larger. Should elm distinguish betweenInt(32 Bit) andLargeInt(53 Bit)? Or should we just fix the json parser?