test: run lua 5.5 tests on the lua 5.5 wasm binding#1723
Open
RealColdFry wants to merge 5 commits into
Open
Conversation
Perryvw
reviewed
May 2, 2026
| // is replaced by a string when it propagates out of a protected call. To | ||
| // preserve `throw undefined` semantics, route through xpcall with a message | ||
| // handler that wraps nil into a sentinel, and unwrap before the user catch. | ||
| // See: https://www.lua.org/manual/5.5/manual.html#8.1 |
Member
There was a problem hiding this comment.
What would be the result if we did not do this workaround? Do we get failing tests? Are we getting unexpected type failures at runtime?
Contributor
Author
There was a problem hiding this comment.
Running the below snippet
ok, err = pcall(function() error(nil) end)
print(ok, err, type(err))In Lua 5.0-5.4, LuaJIT, Luau (Lune) gives
false nil nil
while in 5.5:
false <no error object> string
Without the wrapper, error(nil) in Lua 5.5 surfaces as the string "<no error object>" rather than nil. This breaks the error.spec.ts "throw and catch undefined" test (https://github.com/TypeScriptToLua/TypeScriptToLua/actions/runs/25261709047/job/74069980641?pr=1723#step:6:250).
● throw and catch undefined
expect(received).toEqual(expected) // deep equality
Expected: undefined
Received: "<no error object>"
405 | const luaResult = this.getLuaExecutionResult();
406 | const jsResult = this.getJsExecutionResult();
> 407 | expect(luaResult).toEqual(jsResult);
| ^
408 |
409 | return this;
410 | }
at FunctionTestBuilder.expectToMatchJsResult (test/util.ts:407:27)
at test/unit/error.spec.ts:320:7
Otherwise, in
function doThing() {
throw undefined;
}
function main() {
try {
doThing();
return "didThing";
} catch (
e // e: unknown
) {
if (e === undefined) {
// handle the "thrown undefined" case
return "undefined";
}
if (e instanceof Error) {
return "Error[" + e.message + "]";
}
if (typeof e === "string") {
// Lua 5.5 gives a string
return "string[" + e + "]";
}
return "something else";
}
}
console.log(main());if doThing() threw undefined, on 5.5 e is actually the string <no error object> at runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lua 5.5 changes:
Related to #1676 but doesn't address any of the listed changes there. Note that this incompat is not listed in the issue or in the linked change list: https://www.lua.org/manual/5.5/readme.html#changes (although the change list does link to the incompat list)