Skip to content

Accept a new-generic type parameter as a keyed-table key - #1303

Merged
Frotty merged 2 commits into
masterfrom
feat/keyed-table-generic-key
Sep 10, 2026
Merged

Frotty merged 2 commits into
masterfrom
feat/keyed-table-generic-key

Conversation

@Frotty

@Frotty Frotty commented Sep 10, 2026

Copy link
Copy Markdown
Member

The keyed-table key was typed int, which forced every caller through castTo int — exactly the cost the old <T> containers pay and the reason a native Lua key was impossible: an integer index cannot be hashed as the element. This accepts a new-generic T: type parameter as the key instead. New generics are erased on Lua rather than cast, so the element arrives as itself and becomes the table key directly.

Emitted Lua for a unit key, with no cast and no __wurst_classFromIndex round trip:

u = __wurst_safe_CreateUnit(Player(0), 1751543663, 0., 0., 0.)
__wurst_keyedTableAdd(t, u)
if __wurst_keyedTableContains(t, u) then ...

function __wurst_keyedTableAdd(t, k)       t[k] = true        end
function __wurst_keyedTableContains(t, k)  return t[k] ~= nil end

int keys stay accepted, so nothing that already compiled changes.

Checks: 247 targeted tests across the Lua backend classes, 0 failures.

Known gap: membership is still a call to the stub rather than an index inlined at the call site — the deferred finding from #1302, unchanged here.

@Frotty

Frotty commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 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-09-10T15:07:11.188970Z 1023b61 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: 37a46b33cf

ℹ️ 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 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 1023b61500

ℹ️ 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 ae0d94a into master Sep 10, 2026
3 checks passed
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