From 15ea8d1a0af87516c6843c57b5e5ee80947fc1e8 Mon Sep 17 00:00:00 2001 From: Perryvw Date: Tue, 27 Jan 2026 21:52:32 +0100 Subject: [PATCH 1/3] Add lua 5.5 target --- package-lock.json | 14 ++-- package.json | 2 +- src/CompilerOptions.ts | 1 + src/transformation/visitors/break-continue.ts | 1 + test/cli/parse.spec.ts | 1 + .../__snapshots__/expressions.spec.ts.snap | 71 +++++++++++++++++++ test/unit/expressions.spec.ts | 7 ++ test/util.ts | 5 +- tsconfig-schema.json | 2 +- 9 files changed, 93 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c7687fce..cbe9690d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "jest": "^29.5.0", "jest-circus": "^29.7.0", "lua-types": "^2.13.0", - "lua-wasm-bindings": "^0.3.1", + "lua-wasm-bindings": "^0.5.3", "prettier": "^2.8.8", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", @@ -2481,9 +2481,9 @@ } }, "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz", + "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -4661,9 +4661,9 @@ "license": "MIT" }, "node_modules/lua-wasm-bindings": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/lua-wasm-bindings/-/lua-wasm-bindings-0.3.1.tgz", - "integrity": "sha512-QV5hqeCuBiY8NaIGgoqIXfYDNMLBJz+camshbj24N1etSC9Xl6NYYEcab2eQjoX05xhw09Apmr3C4K2V9QY+Mg==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/lua-wasm-bindings/-/lua-wasm-bindings-0.5.3.tgz", + "integrity": "sha512-GnGSkZmYA2VzkNV/xkwOSoxwNsqEk/EcX6uvRLKQw0pCAxCauTymRO2KmJUIrG/psV3cloaS4Cjsr39iCRkrpQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index fa2670998..e6a53fca5 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "jest": "^29.5.0", "jest-circus": "^29.7.0", "lua-types": "^2.13.0", - "lua-wasm-bindings": "^0.3.1", + "lua-wasm-bindings": "^0.5.3", "prettier": "^2.8.8", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", diff --git a/src/CompilerOptions.ts b/src/CompilerOptions.ts index 7f5562c07..47ada916e 100644 --- a/src/CompilerOptions.ts +++ b/src/CompilerOptions.ts @@ -67,6 +67,7 @@ export enum LuaTarget { Lua52 = "5.2", Lua53 = "5.3", Lua54 = "5.4", + Lua55 = "5.5", LuaJIT = "JIT", Luau = "Luau", } diff --git a/src/transformation/visitors/break-continue.ts b/src/transformation/visitors/break-continue.ts index 87487475d..2e64a38eb 100644 --- a/src/transformation/visitors/break-continue.ts +++ b/src/transformation/visitors/break-continue.ts @@ -19,6 +19,7 @@ export const transformContinueStatement: FunctionVisitor = [LuaTarget.Lua52]: LoopContinued.WithGoto, [LuaTarget.Lua53]: LoopContinued.WithGoto, [LuaTarget.Lua54]: LoopContinued.WithGoto, + [LuaTarget.Lua55]: LoopContinued.WithGoto, [LuaTarget.LuaJIT]: LoopContinued.WithGoto, [LuaTarget.Luau]: LoopContinued.WithContinue, }[context.luaTarget]; diff --git a/test/cli/parse.spec.ts b/test/cli/parse.spec.ts index e06a8fafd..c33af1208 100644 --- a/test/cli/parse.spec.ts +++ b/test/cli/parse.spec.ts @@ -247,6 +247,7 @@ describe("tsconfig", () => { ["luaTarget", "5.2", { luaTarget: tstl.LuaTarget.Lua52 }], ["luaTarget", "5.3", { luaTarget: tstl.LuaTarget.Lua53 }], ["luaTarget", "5.4", { luaTarget: tstl.LuaTarget.Lua54 }], + ["luaTarget", "5.5", { luaTarget: tstl.LuaTarget.Lua55 }], ["luaTarget", "jit", { luaTarget: tstl.LuaTarget.LuaJIT }], ["luaTarget", "luau", { luaTarget: tstl.LuaTarget.Luau }], diff --git a/test/unit/__snapshots__/expressions.spec.ts.snap b/test/unit/__snapshots__/expressions.spec.ts.snap index 7f41b8c0a..e2adff370 100644 --- a/test/unit/__snapshots__/expressions.spec.ts.snap +++ b/test/unit/__snapshots__/expressions.spec.ts.snap @@ -482,6 +482,77 @@ ____exports.__result = a | b return ____exports" `; +exports[`Bitop [5.5] ("~a") 1`] = ` +"local ____exports = {} +____exports.__result = ~a +return ____exports" +`; + +exports[`Bitop [5.5] ("a&=b") 1`] = ` +"local ____exports = {} +a = a & b +____exports.__result = a +return ____exports" +`; + +exports[`Bitop [5.5] ("a&b") 1`] = ` +"local ____exports = {} +____exports.__result = a & b +return ____exports" +`; + +exports[`Bitop [5.5] ("a<<=b") 1`] = ` +"local ____exports = {} +a = a << b +____exports.__result = a +return ____exports" +`; + +exports[`Bitop [5.5] ("a<>>=b") 1`] = ` +"local ____exports = {} +a = a >> b +____exports.__result = a +return ____exports" +`; + +exports[`Bitop [5.5] ("a>>>b") 1`] = ` +"local ____exports = {} +____exports.__result = a >> b +return ____exports" +`; + +exports[`Bitop [5.5] ("a^=b") 1`] = ` +"local ____exports = {} +a = a ~ b +____exports.__result = a +return ____exports" +`; + +exports[`Bitop [5.5] ("a^b") 1`] = ` +"local ____exports = {} +____exports.__result = a ~ b +return ____exports" +`; + +exports[`Bitop [5.5] ("a|=b") 1`] = ` +"local ____exports = {} +a = a | b +____exports.__result = a +return ____exports" +`; + +exports[`Bitop [5.5] ("a|b") 1`] = ` +"local ____exports = {} +____exports.__result = a | b +return ____exports" +`; + exports[`Bitop [JIT] ("~a") 1`] = ` "local ____exports = {} ____exports.__result = bit.bnot(a) diff --git a/test/unit/expressions.spec.ts b/test/unit/expressions.spec.ts index 46ca2f7bd..ee0eab5f4 100644 --- a/test/unit/expressions.spec.ts +++ b/test/unit/expressions.spec.ts @@ -96,6 +96,13 @@ test.each(supportedInAll)("Bitop [5.4] (%p)", input => { .expectLuaToMatchSnapshot(); }); +test.each(supportedInAll)("Bitop [5.5] (%p)", input => { + util.testExpression(input) + .setOptions({ luaTarget: tstl.LuaTarget.Lua55, luaLibImport: tstl.LuaLibImportKind.None }) + .disableSemanticCheck() + .expectLuaToMatchSnapshot(); +}); + test.each(unsupportedIn53And54)("Unsupported bitop 5.3 (%p)", input => { util.testExpression(input) .setOptions({ luaTarget: tstl.LuaTarget.Lua53, luaLibImport: tstl.LuaLibImportKind.None }) diff --git a/test/util.ts b/test/util.ts index 501b24bfb..2871f6e5a 100644 --- a/test/util.ts +++ b/test/util.ts @@ -86,6 +86,7 @@ export function expectEachVersionExceptJit( [tstl.LuaTarget.Lua52]: expectation, [tstl.LuaTarget.Lua53]: expectation, [tstl.LuaTarget.Lua54]: expectation, + [tstl.LuaTarget.Lua55]: expectation, [tstl.LuaTarget.LuaJIT]: false, // Exclude JIT [tstl.LuaTarget.Luau]: false, }; @@ -157,7 +158,7 @@ export abstract class TestBuilder { } protected options: tstl.CompilerOptions = { - luaTarget: tstl.LuaTarget.Lua54, + luaTarget: tstl.LuaTarget.Lua55, noHeader: true, skipLibCheck: true, target: ts.ScriptTarget.ES2017, @@ -444,7 +445,7 @@ export abstract class TestBuilder { // Main file const mainFile = this.getMainLuaCodeChunk(); - const luaTarget = this.options.luaTarget ?? tstl.LuaTarget.Lua54; + const luaTarget = this.options.luaTarget ?? tstl.LuaTarget.Lua55; const { lauxlib, lua, lualib } = getLuaBindingsForVersion(luaTarget); const L = lauxlib.luaL_newstate(); diff --git a/tsconfig-schema.json b/tsconfig-schema.json index 87366ea76..6bffd5e46 100644 --- a/tsconfig-schema.json +++ b/tsconfig-schema.json @@ -50,7 +50,7 @@ "description": "Specifies the Lua version you want to generate code for.", "type": "string", "default": "universal", - "enum": ["5.0", "universal", "5.1", "5.2", "5.3", "5.4", "JIT", "Luau"] + "enum": ["5.0", "universal", "5.1", "5.2", "5.3", "5.4", "5.5", "JIT", "Luau"] }, "noImplicitGlobalVariables": { "description": "Always declare all root-level variables as local, even if the file is not a module and they would be global in TypeScript.", From f4d88307f44d706e901fa187f16916ebb205cbcb Mon Sep 17 00:00:00 2001 From: Perryvw Date: Mon, 16 Feb 2026 18:03:05 +0100 Subject: [PATCH 2/3] Fix failing tests --- test/unit/loops.spec.ts | 1 + test/unit/spread.spec.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/unit/loops.spec.ts b/test/unit/loops.spec.ts index 1591da181..b88e0dbeb 100644 --- a/test/unit/loops.spec.ts +++ b/test/unit/loops.spec.ts @@ -555,6 +555,7 @@ for (const testCase of [ [tstl.LuaTarget.Lua52]: expectContinueGotoLabel, [tstl.LuaTarget.Lua53]: expectContinueGotoLabel, [tstl.LuaTarget.Lua54]: expectContinueGotoLabel, + [tstl.LuaTarget.Lua55]: expectContinueGotoLabel, [tstl.LuaTarget.LuaJIT]: expectContinueGotoLabel, [tstl.LuaTarget.Luau]: () => expectContinueStatement, }); diff --git a/test/unit/spread.spec.ts b/test/unit/spread.spec.ts index 3a1add475..53898aae5 100644 --- a/test/unit/spread.spec.ts +++ b/test/unit/spread.spec.ts @@ -81,6 +81,7 @@ describe("in function call", () => { [tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), + [tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), } ); @@ -95,6 +96,7 @@ describe("in array literal", () => { [tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), + [tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), [tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(), }); From 6441f93916a324b0fd978616a7654c85a6708a7a Mon Sep 17 00:00:00 2001 From: Perryvw Date: Mon, 16 Feb 2026 18:09:02 +0100 Subject: [PATCH 3/3] Missed one more failing test --- test/unit/builtins/math.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/builtins/math.spec.ts b/test/unit/builtins/math.spec.ts index b8f6b2cc3..f3ff1f306 100644 --- a/test/unit/builtins/math.spec.ts +++ b/test/unit/builtins/math.spec.ts @@ -96,6 +96,7 @@ util.testEachVersion("Math.atan2", () => util.testExpression`Math.atan2(4, 5)`, [tstl.LuaTarget.Lua52]: builder => builder.tap(expectMathAtan2), [tstl.LuaTarget.Lua53]: builder => builder.tap(expectMathAtan), [tstl.LuaTarget.Lua54]: builder => builder.tap(expectMathAtan2), + [tstl.LuaTarget.Lua55]: builder => builder.tap(expectMathAtan2), [tstl.LuaTarget.Luau]: builder => builder.tap(expectMathAtan2), });