You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several Lua 5.3 suite files (math.lua, sort.lua, errors.lua, strings.lua, goto.lua) use a checkerror(msg, f, ...) helper that calls pcall(f, ...) and asserts string.find(err, msg) matches a specific substring. We produce the right error category but the wrong phrasing, so dozens of assertions fail.
"bad argument #N to 'X' (T expected, got T)" — verify the exact wording across all stdlib argument-error sites.
"attempt to perform 'n//0'" — integer divide-by-zero (op token included).
"... has no integer representation" — float-to-int conversions (f | 1, f >> 0, bitwise on non-representable floats).
"field 'X'" prefix when arithmetic/indexing fails on a global access (e.g. math.huge << 1 → "field 'huge'").
Why it matters
This is the biggest single lever for suite progress. Likely unlocks 60–150 individual asserts across at least 4 suite files. The work is mechanical: identify each raise site in lib/lua/vm/stdlib* and lib/lua/vm/executor.ex, compare wording to PUC-Lua's luaL_error/luaL_argerror output, adjust.
Suggested approach
Audit the existing Lua.VM.ArgumentError template in lib/lua/vm/argument_error.ex against PUC-Lua's luaL_argerror format.
Add a single helper for "wrong number of arguments to 'X'" and route variadic stdlib functions through it.
For arithmetic-on-globals errors, attach the field hint that :get_field/:get_global already tracks.
Pin each template with a unit test under test/lua/vm/ so the wording is enforced.
Acceptance
New unit tests pinning each error template.
Re-running the suite shows progress in math.lua, sort.lua, errors.lua, strings.lua (some still deferred for other reasons, but their checkerror ranges should shrink or pass).
Problem
Several Lua 5.3 suite files (
math.lua,sort.lua,errors.lua,strings.lua,goto.lua) use acheckerror(msg, f, ...)helper that callspcall(f, ...)and assertsstring.find(err, msg)matches a specific substring. We produce the right error category but the wrong phrasing, so dozens of assertions fail.Concrete templates to match
"wrong number of arguments to 'X'"— when too few/many args (e.g.table.insert({}, 2, 3, 4)). One case already fixed in suite: triage and promote literals/goto/events/nextvar files #251."bad argument #N to 'X' (T expected, got T)"— verify the exact wording across all stdlib argument-error sites."attempt to perform 'n//0'"— integer divide-by-zero (op token included)."... has no integer representation"— float-to-int conversions (f | 1,f >> 0, bitwise on non-representable floats)."field 'X'"prefix when arithmetic/indexing fails on a global access (e.g.math.huge << 1→"field 'huge'").Why it matters
This is the biggest single lever for suite progress. Likely unlocks 60–150 individual asserts across at least 4 suite files. The work is mechanical: identify each
raisesite inlib/lua/vm/stdlib*andlib/lua/vm/executor.ex, compare wording to PUC-Lua'sluaL_error/luaL_argerroroutput, adjust.Suggested approach
Lua.VM.ArgumentErrortemplate inlib/lua/vm/argument_error.exagainst PUC-Lua'sluaL_argerrorformat.:get_field/:get_globalalready tracks.test/lua/vm/so the wording is enforced.Acceptance
math.lua,sort.lua,errors.lua,strings.lua(some still deferred for other reasons, but theircheckerrorranges should shrink or pass).