Repository navigation
fix: preserve integer arithmetic and loop dtype semantics - #9
Merged
Merged
Conversation
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.
Plain negative-literal remainder/floor division and integer true division bypassed dtype dispatch, boolean loop inputs lost arithmetic promotion, and loop-index conditions sent raw Python booleans to strict
wherecalls. Route these arithmetic cases through runtime helpers and emit Python selection for conditions proven to depend only on loop indices and literals, preserving the selected branch dtype.Preserve safe constant folding for loop bounds and assigned negative constants. Fix two latent runtime defects exposed by the wider dispatch: unsigned floor quotients below int64-min now use the documented float64 fallback without changing sign; integer true division rounds once using binary long division instead of rounding large operands first. Add behavioral, runtime, and compiled-backend regressions, update semantics documentation, and review the three intentional division golden changes.
Validation:
make checkin the development-only environment: 960 passed, 96 skipped, 96% coverage.INT64_MIN / -1failure; that issue remains unresolved.Tradeoff: correctly rounded integer division uses exact normalization followed by a fixed 55-step bit loop, increasing call cost and first JIT compilation time. Floating-point division retains its existing path.
Includes #8’s merged type-checker workflows. The combined local gate passes all four checkers, 960 tests, and 96% coverage; an independent merge review approved 2,392 lane comparisons and 24 rejection checks.