Repository navigation
Lua: a missing string in a hashtable is the null string, "" - #1437
Conversation
… nothing is stored
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14a8ecf1f4
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
On Lua, Wurst's null string is
""(EliminateLocalTypes), but the emulatedLoadStranswered nil when nothing was stored. That nil then reached the game's natives, which raise on it.StringLength(LoadStr(h, 1, 1))stopped the thread with "bad argument #1 to 'StringLength' (string expected, got nil)", andLoadStr(h, 1, 1) == nullwas false.Measured on the 3.0.0 client, with a real nil (a missing
LoadStr) passed to each native:StringLength,SubString,StringCase,S2I,S2R,StringHash,GetLocalizedString,BlzSetUnitName,SetTextTagText,BlzFrameSetTextandDisplayTextToPlayer."":SubStringpast the end, anySubStringof"", andStringCase("").So
""is the null string the game's Lua natives use themselves. Making Wurst's null nil instead would have to guard every string argument of a native: 752 sites in one real map and 550 in another, after the existing analysis. It would still not match Jass, because the natives return""where Jass returns null.What changes
LoadStranswers""when nothing is stored, both printed in place (LuaHashtableTranslation) and through its helper (LuaNatives), including a missing parent key, a flushed hashtable and a null hashtable. That adds oneor ""on the string load.LuaNativeLowering.neverNilknows thatLoadStrnever answers nil, so a concatenation with it needs no guard of its own.docs/WC3_RUNTIME.mdrecords the measurements and the convention:null == ""is true on Lua and false on Jass. Matching Jass would mean wrapping every native that returns a string.Tests
LuaHashtableTestschecks thatStringLength(LoadStr(...))is 0 and thatLoadStr(...) == nullholds, on every path (absent parent key, absent child key, flushed hashtable, null hashtable, and the helper), on the interpreter, Jass and Lua.LuaHashtableTestsandLuaNativesTestsare updated.LuaHashtableTests,LuaNativesTests,LuaTranslationTests,LuaBackendAuditTestsandCompiletimeHashtableTestspass locally.Also measured: in Jass,
BlzSetUnitName(u, null)crashes the client. This is recorded in the doc and not changed here.