Skip to content

fix: reconstruct computed and context-resolved enum-domain arguments - #759

Merged
e54-bot merged 1 commit into
mainfrom
fix-746-enum-domain-args
Nov 18, 2026
Merged

e54-bot merged 1 commit into
mainfrom
fix-746-enum-domain-args

Conversation

@e54-bot

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

Copy link
Copy Markdown
Contributor

Refs #724
Fixes #746

Cause

check_param_argument accepted only enum literals for a parameter with an enum domain. A computed value (call, variable), null, an array of members, or a shared constant (Left, Up, All, which Workshop text parses to __ambiguous_enum) was refused as unsupported-enum-domain-mismatch.

Change

  • New reconstruct/enum_domain_args.rs holds the domain check (moved out of reconstruct.rs, which shrinks). It keeps computed values, null and arrays as they are and resolves a shared constant to the member in the parameter's domain.
  • Operands of arithmetic resolve a shared constant to the Vector member (Up * x).
  • A shared constant with no selecting domain is refused by name, not as a nameless __ambiguous_enum value call.

Reproduced (each call had its own reproducer, en-US and zh-CN)

All six refused with wright 0.44.0 and now round-trip to a canonically equal program: setAllowedHeroes (array literal, getAllHeroes(), variable), getLivingPlayers/getOppositeTeam (getTeam(), nested call, Team.2), getPlayers, applyImpulse and startThrottleInDirection (directionTowards, getFacingDirection()), worldVector (Vector.LEFT, computed). The Issue's note that applyImpulse/worldVector/team calls did not refuse holds only for literal constants; computed arguments refuse. No call was dropped.

__ambiguous_enum in aram.ow was this problem: 5 refusals with 0.44.0 on Overwatch-AI-PVE/build/aram.ow, none remain. Another __ambiguous_enum (Up as a multiply operand) in PVE main.zh-CN.ow is fixed by the arithmetic rule.

Not delivered

true in a Color slot (hudText, PVE main.zh-CN.ow) has no OPY form: wright compile rejects it with argument 7 must have semantic type 'Color', got Boolean. It still refuses, naming the argument and domain.

Tests

  • New tests/reconstruction_enum_domain_args.rs: round trip in en-US and zh-CN; it fails on main with the refusals above. Ablating the arithmetic rule fails it.
  • Corpus: mysteryUltimates no longer yields unsupported-enum-domain-mismatch; classification.json updated.
  • opy-provider lpp refusal test: its fixture got its enum-domain issue from a shared constant, which now resolves; it asserts the two remaining codes.
  • fmt, clippy -D warnings (stable and 1.88.0), cargo test --workspace --all-targets --all-features, run_oracle.py, run_native.py, tools/overpy/tests all pass.

Computed values, null and arrays of members are accepted for enum-domain parameters, and shared constants (Left, Up, All) resolve to the parameter's domain. A shared constant with no selecting domain is refused by name. Refs #746.
@Teakowa

Teakowa commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

LGTM

Verified on head 4d625e1 with my own 50-program probe, each compiled, parsed, reconstructed, recompiled and compared with workshop_rs::compare::equivalent in en-US and zh-CN (100 runs per build), on this head and on origin/main (a0bca0b):

  • Every call the Issue lists is fixed for computed arguments. setAllowedHeroes (null, nested arrays, mixed arrays, variable index, conditional), getLivingPlayers/getPlayers/getOppositeTeam (including Team.ALL and a conditional), worldVector (Vector.UP, LEFT, FORWARD, UP + LEFT, computed), applyImpulse and startThrottleInDirection (variable and computed), hudText with null/computed/Color.WHITE slots, and Vector.UP * dynamic all refuse on main and round-trip to an equivalent program here. worldVector(Vector.UP, ...) with a literal shared constant also refused on main, which the Issue text did not expect.
  • Runs that round-trip: 40 on main, 74 on this head. No run that passed on main fails here, and no run reconstructs to a non-equal program.
  • Remaining refusals name the construct (constant 'Up' is shared by several enum domains...; zh-CN names 上). Plain V = Vector.UP, normalize/distance/crossProduct operands, == against a shared constant and a vector array still refuse, because no parameter domain selects the member. The PR body states the by-name refusal but does not list these cases under "Not delivered"; they are outside the argument list of fix: reconstruct enum-domain arguments in convert --target opy #746, so Fixes #746 holds. A follow-up Issue under convert --target opy refuses wright's own compile output (settings, calls, enum domains) #724 may be wanted.
  • The new test fails on main (setAllowedHeroes ... expects an enum member of domain 'Hero', both locales) and passes on the head. The existing reconstruction corpus test passes with the updated classification.json.
  • fmt, clippy -D warnings, cargo test --workspace --all-targets --all-features (857 passed, 0 failed), run_oracle.py (all PASS), run_native.py (193 match, 16 known-gap, 0 regressions), tools/overpy/tests pass. All 9 CI checks pass.
  • Not checked: the external aram.ow and PVE exports named in the PR body.

@e54-bot
e54-bot merged commit 3b1a0be into main Nov 18, 2026
9 checks passed
@e54-bot
e54-bot deleted the fix-746-enum-domain-args branch November 18, 2026 13:44
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.

fix: reconstruct enum-domain arguments in convert --target opy

2 participants