Skip to content

Round-trip compact ranges containing inf/NaN#605

Open
greymoth-jp wants to merge 1 commit into
ron-rs:masterfrom
greymoth-jp:fix/range-inf-nan-start-bound
Open

Round-trip compact ranges containing inf/NaN#605
greymoth-jp wants to merge 1 commit into
ron-rs:masterfrom
greymoth-jp:fix/range-inf-nan-start-bound

Conversation

@greymoth-jp

Copy link
Copy Markdown

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 to RangeFrom but left Range and RangeInclusive unmirrored. The ~8-line fix applies the same handling to the two siblings. Round-trip verified both ways.

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 juntyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @greymoth-jp for catching the issue and writing the fix!

Comment thread src/de/mod.rs
Comment on lines +787 to +794
if self.parser.is_number_start(c)
|| self.parser.check_ident("inf")
|| self.parser.check_ident("inff32")
|| self.parser.check_ident("inff64")
|| self.parser.check_ident("NaN")
|| self.parser.check_ident("NaNf32")
|| self.parser.check_ident("NaNf64")
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please factor this out into a method for the parser, since we now repeat this code a few times?

@greymoth-jp greymoth-jp force-pushed the fix/range-inf-nan-start-bound branch from 56166da to 5150ebe Compare June 28, 2026 13:05
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.

2 participants