Repository navigation
Round-trip compact ranges containing inf/NaN - #605
Conversation
The compact-range serializer emits non-finite start bounds such as `inf..2.0` and `NaN..=2.0`, but the `Range`/`RangeInclusive` deserializers only took the compact-range path when the first byte was recognised by `is_number_start` (digit / + / - / . / b). Because `inf` and `NaN` start with a letter, those inputs failed to deserialize with `ExpectedNamedStructLike`, breaking serialize -> deserialize round-trips. The sibling `RangeFrom` branch already had the inf/NaN ident checks; this applies the same checks to `Range`/`RangeInclusive`.
juntyr
left a comment
There was a problem hiding this comment.
Thanks @greymoth-jp for catching the issue and writing the fix!
56166da to
5150ebe
Compare
The inf/NaN literal check now sits next to any_number as check_any_number_start, so the Range/RangeInclusive and RangeFrom call sites share one definition instead of repeating the same seven-way condition.
|
Thanks @mahirhir, could you please also add a change log entry? |
|
Added, as I put it under a new One thing worth flagging: my branch predates the #585 entry that is on master's Unreleased section now, so the merge may want a hand there. Happy to merge master in if that is easier for you than resolving it. |
The first attempt edited my branch's copy, which was four lines behind master under Unreleased, so the file conflicted at exactly the line the entry goes on. This writes master's bytes plus the one Bug Fixes entry, so the diff this PR shows for CHANGELOG.md is those four lines and nothing else.
Only CHANGELOG.md conflicted: master added an Unreleased "Format Changes" entry for ron-rs#585 on the same lines this branch used for its "Bug Fixes" entry. Both are kept, with Format Changes first to match the order the released sections use. src/parse.rs merged without conflict. Master's work there is in next_bytes_is_float and the escaped-string loop; this branch only adds check_any_number_start next to any_number.
The entry claimed both bounds. Only the start was broken: the guard was is_number_start, which does not recognise inf or NaN, while the end bound already went through any_number.
|
Merged master in ( The conflict turned out to be only
Full suite after the merge: 462 passed, 0 failed. I also fixed my own changelog wording. It said "whose bounds are inf or NaN", which overstates it — only the start bound was broken, since the guard was The two workflow runs sit at |
The compact-range serializer emits
inf..2.0/NaN..=2.0, but the deserializer rejects its own output, so a round-trip fails. PR #602 added float handling toRangeFrombut leftRangeandRangeInclusiveunmirrored. The ~8-line fix applies the same handling to the two siblings. Round-trip verified both ways.