Repository navigation
🐛 fix(xsd): check NaN and decimal range bounds - #2242
Conversation
XML Schema makes NaN equal to itself and unordered with every other float or double. An inclusive NaN bound therefore admits only NaN, and an exclusive NaN bound admits no value. Both validators rejected every value instead, NaN included. Decimal and integer bounds were compared as doubles, which rounds long literals: a negative value too small for a double read as zero and passed minInclusive 0, and integers past 2^53 compared equal to their neighbors. Range facets on decimal and integer types now compare the digits as written. List items and RELAX NG datatypes follow the same rules. Refs tox-dev#1736, follows tox-dev#1968.
1ebf58c to
d617fa3
Compare
Merging this PR will improve performance by 19.21%1 warning, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
XML Schema validation mis-judged some range facets. An inclusive
NaNbound onxs:floatorxs:doublerejected every value,NaNincluded, although XML Schema Part 2 makesNaNequal to itself, so the only value such a bound admits isNaN. #1968 fixedNaNvalues under bounded facets and left this case open. Decimal and integer bounds were also compared as doubles, so values that differ only beyond double precision were ranked the same way against a bound, and a long negative value too small for a double passedminInclusive0. Once this merges,NaNbounds, list items and long decimal and integer values get the verdict the specification gives. This fixes #1736 and covers the decimal bounds that #2164 left open, tracked in #2232. 🔢The float path keeps IEEE doubles and applies one bound rule that treats
NaNthe way XML Schema does, in both the XSD and the RELAX NG datatype check. Decimal and integer facets use the order path that dates already use: each bound is compared with its value as written, digit by digit, with no conversion to a double. The shared order function decides both validators, so they agree on every bound.Behavior changes
NaNbound on a float or double admits onlyNaN. An exclusiveNaNbound admits no value, as before.abc, rejects every value. It used to compare as zero.totalDigits,fractionDigits) still read their limits as doubles. They are tracked in #2232.