Skip to content

Reflection natives answer the same on Jass, Lua and in the interpreter - #1521

Closed
Frotty wants to merge 1 commit into
masterfrom
reflection-parity
Closed

Frotty wants to merge 1 commit into
masterfrom
reflection-parity

Conversation

@Frotty

@Frotty Frotty commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Split out of #1519, which this replaces together with #1520 and #1522. The change is unchanged; #1519's Codex rounds reviewed it.

Problem

  • Jass: typeIdToTypeName, instanceCount and maxInstanceCount search the type ids with a binary search whose leaf returns its class without checking the id. So typeIdToTypeName(0) answered the first class's name and maxTypeId() + 1 the last class's, where Lua answers the defaults ("unknown", 0).
  • Interpreter: it counted one class's objects instead of its allocator group, gave the number of objects ever made as maxInstanceCount, and raised for an unknown number. Compile-time code sees the interpreter.

Change

  • Each leaf of the Jass search checks the id.
  • The interpreter keeps live and peak counts per allocator group (the classes joined by inheritance, ProgramState.classKeyLookup), which is what both targets count, and answers the defaults for an unknown number.
  • BACKLOG.md drops the entry and docs/WC3_RUNTIME.md the two differences.

Tests

LuaTranslationTests.reflectionNativesAnswerAsOnJass and reflectionAnswersDefaultsForNumbersWhichAreNoTypeId now run in the interpreter and on Jass too. Without the change they fail there (the interpreter raises, and Jass answers the first class).

Validation: see the results at the end.

Merging: this and #1520 edit neighbouring lines in ProgramState, BACKLOG.md and docs/WC3_RUNTIME.md, so the second to merge needs master merged in. The union of the three PRs is #1519's tree.

Validation (Windows, bundled Lua 5.3, -PallBackends): LuaTranslationTests 149, InterpreterTests 29, CompiletimeTests 50, NewFeatureTests 42, ClassesTests 128, all passing. Not done: Linux and macOS.

Jass's typeIdToTypeName, instanceCount and maxInstanceCount searched the type ids without bounds: the
search narrows to one id even for a number below the first or above the last, so 0 answered for the first
class and maxTypeId() + 1 for the last. Each leaf now checks the id, so any other number gets the default
("unknown", 0), as on Lua.

The interpreter counted the objects of the class alone, gave as maxInstanceCount the objects ever made,
and raised for an unknown number. It now keeps the live objects and their peak per allocator group, the
classes joined by inheritance, which is what both targets count, and answers the defaults for an unknown
number. reflectionNativesAnswerAsOnJass and reflectionAnswersDefaultsForNumbersWhichAreNoTypeId run in the
interpreter and on Jass too; each fails without its part of the change.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T14:03:23.004292Z 862a469 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 commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

Superseded by #1519, which was merged with the same changes before this split was finished.

@Frotty Frotty closed this Oct 21, 2026
@Frotty
Frotty deleted the reflection-parity branch October 21, 2026 14:01
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