Repository navigation
fix(compiler): preserve trailing comparisons under aggressive size optimization - #681
Conversation
…timization Restrict the tail Skip If rewrite to negated conditions so comparison conditions retain the pinned OverPy canonical control-flow structure. Replace text-based expectations with an oracle-backed differential fixture covering default directives, aggressive alone, combined directives, and preserved negation lowering. Fixes #671
|
Addressed review finding 1 (P2) from The trailing aggressive size rewrite now requires the optimized condition to remain a genuine negation. Negated and double-negated comparisons retain the pinned oracle's canonical Verification on the pushed code, all run in the foreground:
No supplied findings remain unaddressed and no issue/architecture mismatch was found. There are no GitHub review threads to resolve; the finding was supplied in the external review file. The PR is ready for follow-up review. This comment is the explicit handoff for the external review workflow. Remote CI and live game execution have not been verified by this local run. |
When both
#!optimizeForSizeand#!optimizeForSizeAggressiveare enabled, a trailing single-statement comparisonifincorrectly becameSkip If. Restrict the existing tail rewrite to negated conditions so comparisons retain the canonicalIf/Endstructure produced by pinned OverPy 9.7.17.Add the
structural-size-aggressive-control-flowdifferential fixture and replace the old text-based tests with canonical Workshop comparison against its pinned oracle snapshot. The fixture covers default mode, the aggressive directive alone, both directives together, and preserved negation lowering. Ablation removed the obsolete comparison detection/inversion path; no new production mechanism or dependency was added.Fixes #671
Verification
All gates ran in the foreground. Rust builds used
CARGO_INCREMENTAL=0; scratch data and reports are under.task-scratch/orch/scratch-671outside the worktree.pnpm install --dir tools/overpy/oracle --frozen-lockfile— installed pinned OverPy 9.7.17.cargo build --locked -p opy-cli --features compatibility --bin opy-cli --bin opy-compat— passed.opy-compat project-compare --source <repro.opy> --root <scratch> --reference <oracle.workshop>— canonical workshop-rs 1.28.2 comparison reproduced the original divergence before the fix; after the fix,equivalent: true, zero differences. Both size directives were enabled.python3 tools/overpy/run_oracle.py --fixture synthetic/structural-size-aggressive-control-flow --update— generated the differential snapshot from the pinned oracle.cargo test -p opy-rs --lib aggressive_size_control_flow_matches_the_pinned_oracle— failed before the production fix; 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— passed, including differential coverage; one existing ignored test.python3 -m unittest discover -s tools/overpy/tests— 52 tests passed.python3 tools/overpy/run_native.py --binary target/debug/opy-cli --semantic-binary target/debug/opy-compat --results <scratch>/native-results --report <scratch>/native-report.json— 170 fixtures: 155 match, 15 known gaps, zero unexpected divergences. The first attempt hit a 60-second tool timeout; the complete foreground rerun passed.python3 tools/overpy/probe_builtins.py --binary target/debug/opy-compat --jobs 4 --report <scratch>/probe-report.json— 6,114 probes, zero unexplained differences. Invoked through a scratch-only wrapper that retains temporary probe directories under the requested scratch root; probe generation and comparison were unchanged.python3 tools/overpy/structural_gate.py --binary target/debug/opy-compat --workdir <scratch>/structural-gate --report <scratch>/structural-report.json— both pinned Bastion entry points passed, zero unrecorded differences.git diff --check— passed.Limitations
UI gates do not apply: this repository has no
ui/directory. Live game behavior and remote CI were not verified locally.An exploratory check combining
#!disableOptimizationswith both size directives found a separate pre-existing upstream/native control-flow difference. That combination is outside the reported reproduction and remains unchanged; this PR makes no parity claim for it.