Conversation
NaN remains as a sentinel value (.nan, .isNaN) but now traps immediately when used in any computation (arithmetic, rounding, negation, abs, pow). Representation paths (description, doubleValue, decimalValue, codable) still handle NaN gracefully. This catches NaN misuse at the point of error rather than letting it propagate silently through calculations. BREAKING CHANGE: Operations on NaN now trap instead of returning NaN. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover signed and unsigned integer exact conversion including success, fractional rejection, NaN rejection, and out-of-range rejection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Pull request had an unknown failure |
Cover concrete overloads for Int, Int64, and Int32 exact conversion from FixedPointDecimal: success, fractional rejection, NaN rejection, and out-of-range rejection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cand:exponent: traps Also fix stale NaN-propagation example in .nan doc comment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
axelandersson
approved these changes
Mar 27, 2026
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.
Summary
.nansentinel value,.isNaN, and representation paths (description, doubleValue, decimalValue, codable, formatting, comparisons) remain unchangedpreconditionchecksprocessExitsWith: .failureBREAKING CHANGE: Operations on NaN now trap instead of returning NaN. Users who relied on quiet propagation must check
.isNaNbefore operating.Motivation
Quiet NaN propagation can mask bugs — a NaN enters a computation chain and silently corrupts all downstream results, surfacing far from the original error. Signalling NaN catches misuse at the point of error, consistent with how overflow already traps (matching Swift
Intsemantics).Test plan
swift buildcompiles cleanlyswift test— all 564 tests passswiftlint lint— 0 violations🤖 Generated with Claude Code