Repository navigation
fix(compiler): preserve zero slot precedence over capture replacement - #680
Conversation
…lacement Keep zero literals in parameter slots that the size optimizer rewrites to False or Null, before applying a configured zero replacement. Reuse the existing literal-slot policy so arr.index(0) matches pinned OverPy 9.7.17 under optimizeForSize and replace0ByCapturePercentage. Add a canonical differential fixture covering index calls, nested calls, Null and False slots, directive fallback, and directive-only behavior. Fixes #670
…on operands Restore directive replacement for zero operands consumed by max/min self-assignment rewrites, while retaining False for surviving value calls. Preserve comparison zero operands for the existing Null size rewrite. Extend the canonical differential fixture with the four review reproducers and directive-only, disabled-optimization, and rule-condition controls. Refs #670
|
Fixed both findings from review
Extended the existing Foreground verification passed:
No findings were deferred or contradicted the approved issue or architecture. There are no GitHub review threads to reply to or resolve; the findings were supplied in the external review file. The ablation pass retained only the targeted precedence changes and regression coverage. PR #680 is ready for follow-up review. GitHub CI and live-game execution have not been verified; the existing manual resource baseline was not run. No merge performed. |
With both
#!optimizeForSizeand#!replace0ByCapturePercentage,arr.index(0)emittedPoint Capture Percentagewhere pinned OverPy 9.7.17 emitsNull. Lowering now preserves zero literals in slots that already have aFalseorNullsize rewrite, allowing the existing slot policy to take precedence over the directive.A new canonical differential fixture covers
index(0), nested index calls, array membership, a Boolean slot, directive fallback, and directive-only behavior. Its oracle snapshot was generated by the pinned reference and its canonical-program assertion failed before the fix and passed afterward. No public API, dependency, or configuration changes. The ablation/simplification pass retained only the shared slot lookup and precedence guard; no new optimizer mechanism was needed.Fixes #670
Verification
All commands ran in the foreground in the issue worktree. Compatibility acceptance compared canonical programs parsed by workshop-rs 1.28.2 against pinned OverPy 9.7.17.
pnpm install --dir tools/overpy/oracle --frozen-lockfile— installed the pinned oracle.cargo build --locked -p opy-cli --features compatibility --bins— passed (CARGO_INCREMENTAL=0).target/debug/opy-compat project-compare --source <scratch>/repro.opy --root <scratch> --reference <scratch>/reference.workshop— canonical mismatch before the fix;equivalent: true, zero differences afterward. Scratch root:/Users/teakowa/Repos/wrightkit/.task-scratch/orch/scratch-670.python3 tools/overpy/run_oracle.py --fixture synthetic/structural-size-capture-slots --update— generated the successful pinned oracle snapshot.cargo test -p opy-rs --lib literal_slots_take_precedence_over_the_capture_replacement— failed before the production change and passed afterward.cargo fmt --all -- --check— passed.cargo clippy --workspace --all-targets --all-features -- -D warnings— passed.cargo +1.88.0 clippy --workspace --all-targets --all-features -- -D warnings— passed.cargo test --workspace --all-targets --all-features— 835 passed, zero failures; one existing manual resource baseline ignored. Cargo gates usedCARGO_INCREMENTAL=0.python3 -m unittest discover -s tools/overpy/tests— 52 passed.python3 tools/overpy/run_native.py --binary target/debug/opy-cli --semantic-binary target/debug/opy-compat— 170 fixtures: 155 matches, 15 recorded gaps, zero unexpected divergences. The new fixture passes the canonical semantic-WIR comparison.python3 tools/overpy/probe_builtins.py --binary target/debug/opy-compat --jobs 4— 6,114 probes, zero unexplained findings.python3 tools/overpy/structural_gate.py --binary target/debug/opy-compat --workdir <scratch>/structural-gate --report <scratch>/structural-report.json— both pinned Bastion entries pass with zero recorded or unrecorded differences.git diff --check— passed.Unverified
GitHub CI has not been verified. The existing manual resource baseline and live-game execution were not run. UI gates are inapplicable because this change touches no UI files.