Scalarize tuples in the Lua backend - #1261
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43495f3091
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e415c7110a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b370435db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad994db850
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c96e3708ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 982eee608a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7904f0b954
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c8d2051ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
When tuple-returning calls are passed directly as arguments, this turns each call into adjacent expressions such as consume(first(), shared_slot, second(), shared_slot). The auxiliary components use mutable globals shared by the dispatch group, while Lua does not specify expression evaluation order, so an implementation that evaluates or interleaves the later arguments first can read stale slots or let second() overwrite first() before its slot is captured, silently diverging from Jass tuple semantics. Materialize each tuple argument's scalar components in ordered statements before constructing the call argument list.
AGENTS.md reference: AGENTS.md:L217-L221
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the latest P2 in 066517c. Calls receiving a tuple argument now evaluate the dynamic receiver and every original argument left-to-right into scalar locals, then invoke the scalar-only call. This prevents later tuple-returning arguments from overwriting shared return slots and preserves interleaved scalar side effects. Added a real-Lua regression for consume(produce(1), mark(7), produce(2)); focused LuaBackendAuditTests and TupleTests pass. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 066517c8e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ImVar temp = JassIm.ImVar(rhs.attrTrace(), rv.getType(), "tuple_return", false); | ||
| f.getLocals().add(temp); | ||
| stmts.add(JassIm.ImSet(parent.getTrace(), JassIm.ImVarAccess(temp), rhs)); |
There was a problem hiding this comment.
Capture return components before later component preludes
When an earlier tuple component is a mutable read and a later component has been lowered to an ImStatementExpr, flattenTupleExpr moves the later component's statements into stmts before this loop captures any flatExprs. Thus return pair(x, producer().y) returns the modified value of x if producer() changes it, instead of the value read before evaluating the second component. Capture each component at its original flattening position rather than staging all values after every extracted prelude.
AGENTS.md reference: AGENTS.md:L217-L221
Useful? React with 👍 / 👎.
Summary
Acceptance criteria
Verification
./gradlew.bat test— 1,760 tests passed on the completed implementation before the final tuple-only specialization scope cleanupLuaBackendAuditTests,LuaTranslationTests,FieldIterationTests, andFastHashMapTests— passed (190+ tests)git diff --check— cleanFollow-up
Class instances intentionally remain Lua tables in this PR. A separate follow-up will evaluate integer IDs plus per-field arrays with explicit reclamation, including stale-reference semantics, reference cleanup, closure lifetime, and generated-Wurst benchmarks.