Skip to content

v0.1.371 — chained comparison short-circuits like Python (PMAT-672)

Choose a tag to compare

@noahgift noahgift released this 15 Jun 14:59
· 50 commits to main since this release
ae3a965

Correctness (PMAT-672): a chained comparison a < b < c now SHORT-CIRCUITS like Python — it stops at the first false sub-comparison and never evaluates the trailing operands. PMAT-576's flat let __cmpN + && fold hoisted every operand up front, so a panic-prone or side-effecting trailing operand (10 < n < (100 // dv) with dv == 0) ran even when an earlier compare was false — a divide-by-zero panic / spurious side effect where Python returns False. Fixed by emitting a right-nested form (each shared operand bound inside the prior compare's if), which evaluates each operand exactly once (preserving the PMAT-576 single-eval guarantee) AND only when Python would. Found by the HUNT-V5 differential hunt; verified vs python3. 429 e2e fixtures.