Support Interval 2.0 - #14
Draft
robertvansteen wants to merge 2 commits into
Draft
Conversation
Interval no longer accepts a float in its bound comparisons, because a binary float carries no exact decimal value to compare with: the literal 0.1 is not one tenth. The host language still yields int|float scalars, so exact() renders one as the shortest decimal that round-trips to it — the number the source text denoted — and the four ordering operators pass their operand through it. format() took mixed and cast it to string, which quietly accepted anything stringable. It now rejects a value that is not an Interval, with the same TransformValueException the coercions raise. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The float conversion vouched for a guarantee it did not provide. PHP's `(string)` cast on a float honours `precision` — 14 significant digits by default — not `serialize_precision`, so it truncates and can emit exponent notation: `(string) 123456789012345.67` is `1.2345678901235E+14`, which is 123456789012350. A bound sitting between the two compares to the wrong side. `json_encode` honours `serialize_precision` (-1) and yields the shortest decimal that round-trips, which is what the docblock describes. A comparison case with a bound in that gap pins it, and fails on the old cast. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Widens to
superscript/interval ^2.0andgosuperscript/axiom ^0.6.9.Interval 2.0 no longer accepts a float in its bound comparisons, because a binary float carries no exact decimal value to compare with — the literal
0.1is not one tenth. The host language still yieldsint|floatscalars, soexact()renders one as the shortest decimal that round-trips to it, which is the number the source text denoted:format()tookmixedand cast it to string, which quietly accepted anything stringable. It now rejects a value that is not anInterval, with the sameTransformValueExceptionthe coercions raise.Verified against the local chain: PHPStan clean, 28 tests, 100% coverage, MSI 100%.