fix(checker): Int op Nat types as Int — the formal LUB, not a silent Nat assertion - #862
Conversation
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR changes mixed ChangesNumeric join fix and validation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Source as Source expression
participant Checker as _check_binary
participant Join as numeric_join
participant Verifier as overflow classification
Source->>Checker: Int <op> Nat expression
Checker->>Join: numeric_join(left_base, right_base)
Join-->>Checker: Int for mixed Int/Nat, or shared base, or None
Checker-->>Source: synthesised result type
Source->>Verifier: overflow queries
Verifier-->>Source: _overflow_int_type = Int, _overflow_arith_type = Int
Suggested labels: 🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #862 +/- ##
=======================================
Coverage 92.00% 92.00%
=======================================
Files 95 95
Lines 28800 28809 +9
Branches 332 332
=======================================
+ Hits 26497 26506 +9
Misses 2295 2295
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…Nat assertion (#755) Squash of the fix + the review-round div/mod pins and ch09_async reframing. Co-Authored-By: Claude <noreply@anthropic.invalid>
f9f75ad to
575a7d3
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Burndown PR for #755. Mixed
Int <op> Natarithmetic typed asNatwhenever the Int operand came first — the join used bidirectionalis_subtype, and the verifier-mediated narrowing relaxation (Int <: Nat, spec §2.8 rule 5) leaked into the checker's widening join. Typing@Int.0 - 2asNatsilently asserts non-negativity with no obligation behind it (spuriousFuture<Nat>inferences, E503s the author never asked for), violating §0.2.2 no-implicit-behaviour.numeric_joinLUB helper invera/types.py: onlyNat <: Int(the formal refinement subtyping, §2.2.1) participates;Int op Nat→Intfor all five operators, both operand orders.Nat op Nat→NatandInt/Float64mismatches (E141) unchanged.ch09_async.vera'srequires(@Int.0 >= 0)workaround for this exact bug removed.@Int.0 - 2now carriesint_overflow(wasnat_sub); genuine@Nat - @Natkeeps its underflow guard (verified).typecheck_with_artifacts(cannot coincide with a fallback); 3 RED on the unfixed tree; mutation kill: reverting the join flips them RED.@Natnarrowing not obligated at function return position or value-position tuple/constructor components #758 (spec §11.2.1 documents it) — this PR makes the type honest, Verifier:@Natnarrowing not obligated at function return position or value-position tuple/constructor components #758 owns the guard.Orchestrator flip: the branch's type-observation tests fail 3/6 against main's compiler, 6/6 pass on the branch.
Closes #755
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Int/Natbinary arithmetic now consistently yields anIntresult type (withNat <op> NatstayingNatandInt <op> IntstayingInt).@Natcontexts is corrected to match the intended typing rules.Tests
Int/Natresult-typing cases, plus updated overflow-related expectations and metrics.Documentation