Skip to content

Test Lua's targeted generic specialisation against Jass, bounded-exhaustively - #1505

Merged
Frotty merged 9 commits into
masterfrom
generic-specialisation-matrix
Oct 20, 2026
Merged

Frotty merged 9 commits into
masterfrom
generic-specialisation-matrix

Conversation

@Frotty

@Frotty Frotty commented Oct 20, 2026

Copy link
Copy Markdown
Member

On Lua a new generic stays erased except where code needs the concrete type; Jass specialises everything. #1498 came from such a seam (a write through one dispatch path, a read through another), and the existing generators only checked that programs compile. This adds an executing, bounded-exhaustive differential test over that feature space, with Jass as the oracle.

What it does

GenericSpecialisationMatrixTests generates one self-checking program per combination of:

  • what depends on T: a per-instantiation static, a fixed-argument store inside the generic (the Fix concrete generic stores behind erased Lua dispatch #1498 shape), a type-class bound requirement, wurstNewInstance<T>(), instanceof Box<T>, a T-typed (tuple when T is) field;
  • where it sits: method, second constructor, ondestroy, closure, inherited from a generic superclass, module-injected;
  • how concrete code writes it and reads it (chosen separately): direct, non-generic base class, non-generic interface, generic interface, closure, super call, destroy, erased generic function;
  • instantiation types int, string, class, tuple; one or two instantiations;
  • flags none or -inline -localOptimizations.

Each program runs translated to Jass in the Jass interpreter and translated to Lua in Lua. Combinations that are not programs are skipped with a named reason (wurstNewInstance needs a class; a module member cannot override a superclass method). A rejection no rule predicts fails.

  • Pull-request tier: a 384-case covering subset (every pair of dimension values, plus every dependency × writer × reader), about 50–80 s locally.
  • Full product: WURST_GENERIC_MATRIX=full runs all 36,864 cases (about an hour locally), sharded with WURST_GENERIC_MATRIX_SHARD=i/n to fit the test task's limit. WURST_GENERIC_MATRIX_KEEP_GOING and WURST_GENERIC_MATRIX_FILTER support campaigns and repros.

What it found

Jass passes every case. On master (with #1498), 165 of the 384 tier cases fail on Lua. They are listed in genericSpecialisationMatrix-knownFailures.txt under nine defect tags and skipped with the tag and the failure, so CI stays green and any other failure fails the test. Each tag has a BACKLOG.md entry with a minimal repro:

tag defect
lua-static-erased per-instantiation static read through erased code: shared between instantiations or never initialised
lua-instanceof-erased Box<string> is instanceof Box<int> (no generic code needed)
lua-bound-unresolved Lua rejects a bound requirement reached through an interface, base class, super or destroy
lua-closure-receiver Lua rejects a closure in a bounded generic class that touches a field
lua-new-instance-unresolved Lua rejects wurstNewInstance<T>() in a constructor, an ondestroy or behind super
lua-new-instance-erased wurstNewInstance<T>() via an interface: translation crash, or null with optimisations
lua-field-split a T field written through another instance is not the one read back
lua-tuple-subclass a subclass of a tuple-instantiated generic: nil field storage, ConcurrentModificationException, dangling dispatch
lua-tuple-elimination-crash EliminateTuples throws on tuple-typed generic code (one shape on both targets)

There is also a Jass defect: this.field instanceof Box<T> in a generic class fails translation. The matrix reads a local copy instead, and the defect has its own BACKLOG entry.

Proof

Tested on Windows with the bundled Lua 5.3. The Linux CI uses lua5.3; macOS (master CI) installs Homebrew's Lua, whose version is not pinned. The list is keyed by case name, and a listed case that passes there only produces a summary note.

…ustively

GenericSpecialisationMatrixTests generates a self-checking program per
combination of what depends on T (per-instantiation static, fixed-argument
store, type-class bound, wurstNewInstance, instanceof Box<T>, T-typed field),
where it sits (method, constructor, ondestroy, closure, inherited, module),
how concrete code writes and reads it (direct, non-generic base, non-generic
interface, generic interface, closure, super, destroy, erased generic
function), the instantiation types (int, string, class, tuple; one or two)
and the optimiser flags. Each program runs translated to Jass in the Jass
interpreter, the oracle, and translated to Lua in Lua.

Pull requests run a 384-case covering subset (all pairs, plus every
dependency x writer x reader), about a minute. WURST_GENERIC_MATRIX=full
runs the 36,864-case product, in shards for master or nightly runs.

The 179 subset cases that fail on master are listed with their defect class
in genericSpecialisationMatrix-knownFailures.txt and reported as skipped;
any other failure fails the test. Jass passes every case.
With #1498 on master the fixed-store cases pass, so the known-failure list
now holds the 165 tier cases that still fail. Each is tagged with the defect
it shows, and each tag has a BACKLOG.md entry with a minimal repro:
per-instantiation statics read through erased code, instanceof across
non-tuple instantiations, bound requirements and wurstNewInstance behind
erased dispatch, closures in bounded classes, fields written through another
instance, subclasses of tuple-instantiated generics and an EliminateTuples
crash. The Jass instanceof-on-a-field defect the generator steps around has
an entry too. The full product fails in no other class, and Jass passes
every case.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T15:20:29.825930Z a35e278 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27a6236b88

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

…s with luac

A case in the known-failure list was skipped on any failure, so a Jass
(oracle) regression or a new Lua symptom in a listed case left the run
green. defectOf now classifies a failure by its symptom, and a listed case
is skipped only while it fails on Lua, with Jass passing, with the listed
defect; otherwise it fails and says how it was listed. All 165 listed cases
classify as listed.

The matrix's own Lua runner skipped the luac syntax check that every
executing Lua test makes. It now checks each script before running it: a
missing luac fails, a missing interpreter skips the run only.
@Frotty

Frotty commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c88bd80c68

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

A listed STATIC or NEW_INSTANCE case, or a BOUND or FIELD case in a
constructor or ondestroy, was skipped for any Lua run-time failure, since
the defect follows from what the case depends on. Each entry now also holds
the symptom: the wrong value the program reports, or the compiler's message
without the numbers of generated names. For an error Lua raises it holds
only that Lua raised, because those messages differ between Lua versions and
the test hosts do not pin one. A listed case is skipped only when its defect
and its symptom match.
@Frotty

Frotty commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a01410eba

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

…he list

On a host without a Lua interpreter the Lua side skipped the case after the
Jass result was known, so a Jass failure was reported as skipped. A case now
fails when Jass fails and skips only its Lua run when Jass passes.

The list a run writes for updating the known failures held only the cases
that run decided, so a shard or a filtered run dropped every other entry.
It now starts from the existing list and replaces the cases that ran.
@Frotty

Frotty commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a35e278224

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

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