Skip to content
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

fix #15413: support JSON in int64.high+1..uint64.high as JUint, and beyond as JNumber #15545

Closed
wants to merge 11 commits into from

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Oct 10, 2020

fix #15413

see rationale here: #15413 (comment), in particular wrt BigInt vs uint64

the only breakage caused by this change was in a single package, nimpy.nim(821, 3) Error: not all cases are covered; missing: {JUInt, JNumber} and I've already fixed that in yglukhov/nimpy#177 using trailing else.

(this could've also been fixed by #15646, after which I'd add {.allowMissingCases.} pragma as described in #15646)

@timotheecour timotheecour changed the title fix https://github.com/nim-lang/Nim/issues/15413: support JSON in int64.high+1..uint64.high fix #15413: support JSON in int64.high+1..uint64.high Oct 10, 2020
@timotheecour timotheecour changed the title fix #15413: support JSON in int64.high+1..uint64.high fix #15413: support JSON in int64.high+1..uint64.high as JUint, and beyond as JNumber Oct 19, 2020
@disruptek
Copy link
Contributor

How does deprecation work?

@timotheecour
Copy link
Member Author

timotheecour commented Oct 20, 2020

How does deprecation work?

EDIT:
2 options:

@timotheecour timotheecour force-pushed the pr_fix_json_uint64 branch 2 times, most recently from d608fe8 to 72c3539 Compare October 20, 2020 18:37
timotheecour added a commit to timotheecour/nimpy that referenced this pull request Oct 20, 2020
yglukhov pushed a commit to yglukhov/nimpy that referenced this pull request Oct 21, 2020
@timotheecour
Copy link
Member Author

timotheecour commented Oct 21, 2020

PTAL, green now, see above comments in #15545 (comment) for how to handle backward+forward compatibility

@timotheecour timotheecour requested a review from Araq October 26, 2020 01:05
yglukhov added a commit to yglukhov/nimpy that referenced this pull request Oct 26, 2020
yglukhov added a commit to yglukhov/nimpy that referenced this pull request Oct 26, 2020
@jackhftang
Copy link
Contributor

Please consider carefully before adding any new JSON kind! If you regret later, this will be a breaking change. This cannot be undone and the interface will ruin.

Copy link
Contributor

@dom96 dom96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break code, we shouldn't merge it until it there is a transition path.

@timotheecour
Copy link
Member Author

timotheecour commented Oct 28, 2020

This will break code, we shouldn't merge it until it there is a transition path.

I've suggested #15646 as a way to avoid breaking changes (instead a warning would be issued until clients upgrade their code; in particular if this PR was modified to apply to individual enum members instead of the whole enum) but this was closed, and I've also suggested affected code be patched with simply adding a trailing else which is forward and backward compatible, ie after the trailing else is added to affected code it will work with both new and old enum.

What is your alternative suggestion to fix #15413 and make nim parse valid json strings involving numbers (eg uint64 that don't fit int64, or beyond uint64/int64/float64) that also doesn't break any code (nor introduce ambiguities as suggested in #15413 (comment) [1])?

[1] which can't distinguish string from unparsable numbers and makes certain tasks difficult in presence of those unparseable numbers, eg pretty-printing a json string, filter a json string or more generally any json=>process=>json program

@Araq
Copy link
Member

Araq commented Oct 29, 2020

which can't distinguish string from unparsable numbers

It can do that... Not that it's a big deal anyway.

@Araq Araq closed this Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON parsing fails for integer values greater than BiggestInt.max
5 participants