Skip to content

fix(compiler): preserve zero slot precedence over capture replacement - #680

Merged
e54-bot merged 2 commits into
mainfrom
fix/670-optimize-for-size-capture
Oct 29, 2026
Merged

e54-bot merged 2 commits into
mainfrom
fix/670-optimize-for-size-capture

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

With both #!optimizeForSize and #!replace0ByCapturePercentage, arr.index(0) emitted Point Capture Percentage where pinned OverPy 9.7.17 emits Null. Lowering now preserves zero literals in slots that already have a False or Null size 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).
  • Oracle CLI compilation of the minimal issue reproduction, followed by 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 used CARGO_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.

…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
@e54-bot

e54-bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Fixed both findings from review 670-r1.md in commit 61c4889 (pushed to fix/670-optimize-for-size-capture):

  • P1: Zero operands consumed by max/min self-assignment-to-Modify rewrites retain directive replacement. Max/min calls that survive as values retain False precedence.
  • P2: Direct and nested value comparisons preserve zero for the existing Null size rewrite. The already-matching rule-condition path remains covered.

Extended the existing synthetic/structural-size-capture-slots differential fixture with all four reproducers, surviving max/min value calls, directive-only and optimizations-disabled controls, and a rule-condition control. Regenerated its snapshot with pinned OverPy 9.7.17. The canonical assertion failed before the production fixes and passed afterward. Each isolated review reproducer also passes opy-compat project-compare with zero differences. Compatibility acceptance compares canonical programs parsed by workshop-rs 1.28.2 against pinned OverPy 9.7.17.

Foreground verification passed:

  • cargo fmt --all -- --check
  • Stable and Rust 1.88.0 cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets --all-features: 835 passed, zero failures; one existing manual resource baseline ignored.
  • python3 -m unittest discover -s tools/overpy/tests: 52 passed.
  • Native corpus: 155 matches, 15 recorded gaps, zero unexpected divergences.
  • All 6,114 builtin probes: zero unexplained findings.
  • Pinned Bastion structural gate: both entries have zero canonical differences.
  • git diff --check

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.

@e54-bot
e54-bot merged commit 6b0ed28 into main Oct 29, 2026
8 checks passed
@e54-bot
e54-bot deleted the fix/670-optimize-for-size-capture branch October 29, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opy-rs: replace0By directive changes arr.index(0) slot emission

2 participants