Round-trip compact ranges containing inf/NaN#605
Open
greymoth-jp wants to merge 1 commit into
Open
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
reviewed
Jun 26, 2026
juntyr
left a comment
Member
There was a problem hiding this comment.
Thanks @greymoth-jp for catching the issue and writing the fix!
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") | ||
| { |
Member
There was a problem hiding this comment.
Could you please factor this out into a method for the parser, since we now repeat this code a few times?
56166da to
5150ebe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.