Skip to content

fix: reconstruct attacker, victim and removeFromArray value calls in convert --target opy - #762

Merged
e54-bot merged 1 commit into
mainfrom
fix-744c-reconstruct-value-calls
Nov 18, 2026
Merged

e54-bot merged 1 commit into
mainfrom
fix-744c-reconstruct-value-calls

Conversation

@e54-bot

@e54-bot e54-bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Refs #724
Refs #744

Replaces the closed #758 (three review rounds, one defect class).

Change

convert --target opy reconstructs these value calls (reconstruct/value_literals.rs):

  • attacker, victim, healer, healee (no arguments) as the bare OPY keyword;
  • removeFromArray(array, value) as (array).exclude(value).

A Set whose removeFromArray operand is its own target recompiles to a Modify form (self_modification in compiler/operator_optimization.rs). reconstruct/self_removal.rs detects that shape by calling the same function on the Workshop action, so the comparison is structural (same variable, same player, same index value) and never a rendered-text comparison. The shape is refused with unsupported-value-call naming removeFromArray, for global and player variables, plain and indexed. indexed_target moved into that file so reconstruct.rs does not grow.

Out of scope: the arithmetic indexed Set (#761).

Tests (tests/reconstruction_self_removal.rs)

Inputs are Workshop text, run in en-US and zh-CN (the zh-CN text is the same program re-emitted by workshop_rs::emitter):

  • plain and indexed self-referential Sets, global and player: refused;
  • indexes that differ only in grouping, g[(h + i) * 2] against g[h + i * 2], global and player: round trip, not refused;
  • different array, and the Modify form: round trip.
    The round-trip tests fail on main. The refusal tests fail with the guard call removed. classification.json drops unsupported-value-call from mysteryUltimates.

Reproduction

Gates

fmt, clippy (stable and 1.88.0, -D warnings), cargo test --workspace --all-targets --all-features, tools/overpy/tests, run_oracle.py and run_native.py pass.

…convert --target opy

A Set whose removeFromArray operand is its own target (plain or indexed, global or player) recompiles to a Modify form, so it is refused by construct name using the optimizer's structural self-reference predicate. Refs #744
@Teakowa

Teakowa commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

LGTM

VERIFIED on head a7dde8392e57941a6372c37be73d2036379258cb. No findings.

Probes from rounds 1–3 of #758 and new ones, as Workshop text through wright convert --target opy with the worktree's opy-provider, then recompile:

  • Refused with unsupported-value-call naming removeFromArray: the self-referential Set, plain and indexed, global and player, with Event Player and Victim targets, nested (g = Remove From Array(g, Remove From Array(g, 1))), inside If and While, a variable index (g[h]), and Attacker.P on Attacker.
  • Round trip byte-equal (not refused): a different target or array, the Modify forms (g.remove(x), g[1].remove(5)), g = g.exclude(1).exclude(2), g = h.exclude(1).exclude(g), g[1] = [g[1].exclude(5)], g[1] = g[2].exclude(5), g[h] = g[i].exclude(5), a variable copy (h = g; g = h.exclude(1)), a First Of operand, another player's array, and the grouping case g[(h + i) * 2] = g[h + i * 2].exclude(5) for global and player variables.
  • Index expressions equal as values but written differently: g[h + 1] with operand g[1 + h], and g[h + i] with g[i + h], round trip byte-equal. They are not refused, which is correct because the compiler's own self_modification does not treat them as one element, so they recompile to the same Set. g[h + 1] with the identical g[h + 1] is refused, as it should be. The guard calls self_modification on the Workshop action, so it is structural and cannot disagree with the optimizer.
  • OPY-origin round trip (attacker, victim, healer, healee, .exclude in conditions, assignments, arguments and nesting): en-US and zh-CN byte-equal. The pinned OverPy 9.7.17 accepts the reconstructed OPY.

Tests: reconstruction_self_removal.rs inputs are Workshop Set text. With the guard call disabled, both refusal tests fail and the other three pass. Against main's src, the three round-trip tests fail (value call 'attacker' ...).

Gates on this head: cargo fmt --check, clippy --workspace --all-targets --all-features -D warnings, cargo test --workspace --all-targets --all-features (862 passed, 0 failed), run_oracle.py (exit 0, 209 PASS), run_native.py (209 fixtures), tools/overpy/tests (OK).

PR body: Refs #724 / Refs #744, no Fixes. The __ambiguous_enum and mysteryUltimates statement matches classification.json (only unsupported-settings remains; the corpus gate passes). Not checked: the 1.88.0 clippy run from the body.

@e54-bot
e54-bot merged commit 1477279 into main Nov 18, 2026
9 checks passed
@e54-bot
e54-bot deleted the fix-744c-reconstruct-value-calls branch November 18, 2026 14:57
@e54-bot e54-bot mentioned this pull request Nov 18, 2026
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.

2 participants