Skip to content

Keep tuple vararg loop bindings rooted through lowering - #1269

Merged
Frotty merged 3 commits into
masterfrom
codex/lower-tuple-vararg-loop-scalars
Aug 29, 2026
Merged

Keep tuple vararg loop bindings rooted through lowering#1269
Frotty merged 3 commits into
masterfrom
codex/lower-tuple-vararg-loop-scalars

Conversation

@Frotty

@Frotty Frotty commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

  • represent vararg-loop bindings explicitly in IM instead of retaining one tuple variable reference
  • expand tuple-valued loop bindings to their ordered scalar locals during tuple elimination
  • teach copying, rooting checks, liveness, side-effect analysis, local merging, inlining, the interpreter, and Lua emission about the explicit bindings
  • add a focused optimized Lua regression for a generic vararg method specialized with a tuple of handles

Root cause

Lua retains ImVarargLoop until backend emission. Tuple elimination replaced the tuple local in the function's locals with scalar locals, but the loop still referenced the detached tuple variable. Local optimization then inspected that stale variable and failed with Variable ... not attached.

The IM now owns a list of binding nodes which reference the live locals. Before tuple elimination the list has one binding; tuple elimination replaces it with one binding per scalar leaf. Lua consumes that lowered representation directly instead of reconstructing tuple membership from translator state.

Verification

  • ./gradlew.bat compileJava
  • ./gradlew.bat compileTestJava
  • ./gradlew.bat test --tests "tests.wurstscript.tests.LuaBackendAuditTests.optimizedTupleVarargLoopUsesAttachedScalarLocals" --tests "tests.wurstscript.tests.VarargTests"
  • ./gradlew.bat shadowJar
  • Castle Fight PR 65 map build using the resulting wurstscript.jar: passed with exit code 0; no tracked Castle Fight files changed

The full suite was intentionally left to CI.

Context: https://github.com/Frotty/wurst-castle-fight/pull/65

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T21:22:13.028494Z 042c82c Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty

Frotty commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 042c82c8ba

ℹ️ 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".

@Frotty
Frotty merged commit 1980274 into master Aug 29, 2026
6 checks passed
@Frotty
Frotty deleted the codex/lower-tuple-vararg-loop-scalars branch August 29, 2026 22:02
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.

1 participant