Repository navigation
Conversation
…ic class The collector of generic uses overrode the visits of ImInstanceof, ImTypeIdOfObj and ImDealloc without visiting their operand, so in a generic class `held instanceof Box<T>`, `held.typeId` and a captured local in a closure kept the unspecialised field and Jass class elimination found no field array for it. Generic elimination also left the program's cached type ids and subclass lists as they were before it added the specialised classes. Compile-time code fills them (a typeId read through the interpreter), so the Jass build then found no type id for an instantiation's class. Both generics entries now clear them. The specialisation matrix reads the field in its instanceof cases directly instead of through a local copy. BACKLOG.md drops the fixed Jass entry, and the GetHandleId entry says what is and is not shown: the remap's desync reason was never measured, and the game's ids are no contract a program can index by.
Clearing the cached type ids made Jass number every class again after the generics, so a type id which compile-time code had stored as a constant (`compiletime(new Plain().typeId)`) no longer matched the class when the instantiations of a generic class sort before it. Before, the stale cache crashed the build instead. The interpreter now records whether the program read a type id (a typeId, or a Reflection native). When compile-time code did, the translator keeps the ids the classes had then, numbers the classes the generics add after them (TypeId.keeping), and class elimination and the allocators take that numbering. A program whose compile-time code reads no type id keeps the numbering it had. The Jass instanceof checks and the dispatch take a list of ids, so the ids need not be contiguous.
The Lua translation numbered its classes again from the ones the script keeps, so a type id compile-time code had stored no longer matched its class when a class sorting before it was dropped as unused. Lua now takes the ids remembered when compile-time code read them, as Jass does (TypeId.keeping along the nominal superclasses).
Compile-time code sees one class for all the instantiations of a new-generic class, as Lua does; Jass makes a class of each instantiation after compile time. A type id compile-time code read of such a class is so the id of none of them, and the Jass build put it into the script as if it were. (Before the type ids were kept, the build crashed on it.) The interpreter now records where compile-time code first read the type id of a new-generic class, and the Jass numbering stops with an error there when the generics replaced the class. Lua keeps one class for the instantiations, so the id stays right there, which a test pins.
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. |
|
Superseded by #1519, which was merged with the same changes before this split was finished. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1534b6c8b3
ℹ️ 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".
|
|
||
|
|
||
| public ILconstString typeIdToTypeName(ILconstInt typeId) { | ||
| interpreter.noteTypeIdsRead(); |
There was a problem hiding this comment.
Reject generic IDs discovered through reflection
When compile-time code discovers an ID by iterating through maxTypeId() and calling typeIdToTypeName(i), this records only the blanket read flag and never adds the resolved ImClass to genericTypeIdReads. For a new-generic Box<T:>, Jass therefore misses the intended diagnostic: TypeId.keeping leaves the pre-specialization Box ID as an unused gap and assigns Box<int> a later ID, so a discovered and stored constant silently refers to no runtime class. Record the resolved class via noteTypeIdRead (or otherwise reject this indirect read).
AGENTS.md reference: AGENTS.md:L67-L70
Useful? React with 👍 / 👎.
Split out of #1519, which this replaces together with #1521 and #1522. The changes are unchanged; #1519's four Codex rounds reviewed them.
Problem
instanceofortypeIdin a new-generic class failed translation ("Could not find field array for this.G_held"). The same happened for a local captured by a closure. The collector of generic uses inEliminateGenericsoverrode the visits ofImInstanceof,ImTypeIdOfObjandImDeallocwithout visiting their operand.compiletime(new Plain().typeId)) stale. That happens on Jass when instantiations sort before the class, and on Lua when an unused class before it is dropped.Change
typeId, or aReflectionnative). Only when compile-time code did,ImTranslatorkeeps the ids the classes had then. The classes the generics add are numbered after them (TypeId.keeping), on Jass inEliminateClassesand the allocators, and on Lua inLuaTranslator.typeIds(). Jassinstanceofand dispatch take id lists, so the ids need not be contiguous. Programs whose compile-time code reads no type id keep their numbering.GenericSpecialisationMatrixTestsreads the field directly in itsinstanceofcases.BACKLOG.mddrops the Jass entry and rewrites theGetHandleIdentry to claim only what is shown.docs/WC3_RUNTIME.mdrecords the kept ids.Tests
GenericsTestsgains 8 regressions, each failing without its fix: fieldinstanceof, a captured local, fieldtypeId, a compile-timetypeIdread, a stored id against instantiations, a stored id against an unused class, and the generic instantiation case (an error on Jass, correct on Lua).Validation: see the results at the end.
Validation (Windows, bundled Lua 5.3,
-PallBackends): GenericsTests 81, LuaTranslationTests 149, CompiletimeTests 50, NewFeatureTests 42, GenericSpecialisationMatrixTests 384, InterpreterTests 29, LuaBackendAuditTests 285, DeterministicChecks 29, ClassesTests 128, GenericsWithTypeclassesTests 119, all passing. On #1519 (this change plus the other two): the full suite, 3,259 tests, and the full specialisation matrix, 36,864 cases with no failures. Not done: Linux and macOS (PR CI covers Ubuntu only).