Skip to content

Document and pin how an object with a reused id starts on each target - #1540

Merged
Frotty merged 1 commit into
masterfrom
doc-reused-field-defaults
Oct 22, 2026
Merged

Frotty merged 1 commit into
masterfrom
doc-reused-field-defaults

Conversation

@Frotty

@Frotty Frotty commented Oct 22, 2026

Copy link
Copy Markdown
Member

When new reuses the id of a destroyed object, a field without an initialiser starts differently on each target. Nothing documented or tested which one was intended. This PR keeps the current behaviour, and documents and pins it.

Where A field without an initialiser, after id reuse
Jass Keeps what the destroyed object left, including an array field's elements.
Lua Starts from the field's default. new writes every field's default, and gives each array field a fresh table.
Compile-time code (the interpreter before the Jass transformation) Starts from the default, because the interpreter makes a fresh object.

A field with an initialiser starts from it everywhere.

Jass stays as it is. Resetting would add a store per field to every allocation and change what existing maps read.

Changes:

  • docs/WC3_RUNTIME.md, "Objects and memory": the three behaviours and why they differ.
  • WURST_LANGUAGE.md: such a field has no defined starting value in a reused object, so give it an initialiser or assign it in the constructor.
  • LuaTranslationTests:
    • reusedObjectKeepsAFieldWithoutInitialiserOnJass runs after the Jass transformation, with a Lua exemption under OBJECT_BOOKKEEPING.
    • reusedObjectStartsFromTheFieldDefaultsOnLua runs on Lua.
    • reusedObjectStartsFromTheFieldDefaultsAtCompileTime bakes the compile-time result into a constant, which every backend then checks.

The three tests pass both plainly and with -PallBackends. Only Windows was run.

A field without an initialiser keeps the destroyed object's value on Jass, where resetting it
would add a store per field to every allocation and change what existing maps read; Lua writes
every field's default at allocation, and the compile-time interpreter makes a fresh object. The
runtime notes and the language reference say so, and three tests pin each behaviour.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-10-22T09:40:18.726681Z 0fc7996 PR opened
ℹ️ 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 merged commit 937e704 into master Oct 22, 2026
2 checks passed
@Frotty
Frotty deleted the doc-reused-field-defaults branch November 25, 2026 08:54
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