Skip to content

Commit 8a0a85d

Browse files
authored
Add lua 5.5 target (#1680)
* Add lua 5.5 target * Fix failing tests * Missed one more failing test
1 parent e1f5d4f commit 8a0a85d

File tree

12 files changed

+97
-11
lines changed

12 files changed

+97
-11
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"jest": "^29.5.0",
6666
"jest-circus": "^29.7.0",
6767
"lua-types": "^2.13.0",
68-
"lua-wasm-bindings": "^0.3.1",
68+
"lua-wasm-bindings": "^0.5.3",
6969
"prettier": "^2.8.8",
7070
"ts-jest": "^29.2.5",
7171
"ts-node": "^10.9.2",

src/CompilerOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export enum LuaTarget {
6767
Lua52 = "5.2",
6868
Lua53 = "5.3",
6969
Lua54 = "5.4",
70+
Lua55 = "5.5",
7071
LuaJIT = "JIT",
7172
Luau = "Luau",
7273
}

src/transformation/visitors/break-continue.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const transformContinueStatement: FunctionVisitor<ts.ContinueStatement> =
1919
[LuaTarget.Lua52]: LoopContinued.WithGoto,
2020
[LuaTarget.Lua53]: LoopContinued.WithGoto,
2121
[LuaTarget.Lua54]: LoopContinued.WithGoto,
22+
[LuaTarget.Lua55]: LoopContinued.WithGoto,
2223
[LuaTarget.LuaJIT]: LoopContinued.WithGoto,
2324
[LuaTarget.Luau]: LoopContinued.WithContinue,
2425
}[context.luaTarget];

test/cli/parse.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ describe("tsconfig", () => {
247247
["luaTarget", "5.2", { luaTarget: tstl.LuaTarget.Lua52 }],
248248
["luaTarget", "5.3", { luaTarget: tstl.LuaTarget.Lua53 }],
249249
["luaTarget", "5.4", { luaTarget: tstl.LuaTarget.Lua54 }],
250+
["luaTarget", "5.5", { luaTarget: tstl.LuaTarget.Lua55 }],
250251
["luaTarget", "jit", { luaTarget: tstl.LuaTarget.LuaJIT }],
251252
["luaTarget", "luau", { luaTarget: tstl.LuaTarget.Luau }],
252253

test/unit/__snapshots__/expressions.spec.ts.snap

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,77 @@ ____exports.__result = a | b
482482
return ____exports"
483483
`;
484484
485+
exports[`Bitop [5.5] ("~a") 1`] = `
486+
"local ____exports = {}
487+
____exports.__result = ~a
488+
return ____exports"
489+
`;
490+
491+
exports[`Bitop [5.5] ("a&=b") 1`] = `
492+
"local ____exports = {}
493+
a = a & b
494+
____exports.__result = a
495+
return ____exports"
496+
`;
497+
498+
exports[`Bitop [5.5] ("a&b") 1`] = `
499+
"local ____exports = {}
500+
____exports.__result = a & b
501+
return ____exports"
502+
`;
503+
504+
exports[`Bitop [5.5] ("a<<=b") 1`] = `
505+
"local ____exports = {}
506+
a = a << b
507+
____exports.__result = a
508+
return ____exports"
509+
`;
510+
511+
exports[`Bitop [5.5] ("a<<b") 1`] = `
512+
"local ____exports = {}
513+
____exports.__result = a << b
514+
return ____exports"
515+
`;
516+
517+
exports[`Bitop [5.5] ("a>>>=b") 1`] = `
518+
"local ____exports = {}
519+
a = a >> b
520+
____exports.__result = a
521+
return ____exports"
522+
`;
523+
524+
exports[`Bitop [5.5] ("a>>>b") 1`] = `
525+
"local ____exports = {}
526+
____exports.__result = a >> b
527+
return ____exports"
528+
`;
529+
530+
exports[`Bitop [5.5] ("a^=b") 1`] = `
531+
"local ____exports = {}
532+
a = a ~ b
533+
____exports.__result = a
534+
return ____exports"
535+
`;
536+
537+
exports[`Bitop [5.5] ("a^b") 1`] = `
538+
"local ____exports = {}
539+
____exports.__result = a ~ b
540+
return ____exports"
541+
`;
542+
543+
exports[`Bitop [5.5] ("a|=b") 1`] = `
544+
"local ____exports = {}
545+
a = a | b
546+
____exports.__result = a
547+
return ____exports"
548+
`;
549+
550+
exports[`Bitop [5.5] ("a|b") 1`] = `
551+
"local ____exports = {}
552+
____exports.__result = a | b
553+
return ____exports"
554+
`;
555+
485556
exports[`Bitop [JIT] ("~a") 1`] = `
486557
"local ____exports = {}
487558
____exports.__result = bit.bnot(a)

test/unit/builtins/math.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ util.testEachVersion("Math.atan2", () => util.testExpression`Math.atan2(4, 5)`,
9696
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectMathAtan2),
9797
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectMathAtan),
9898
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectMathAtan2),
99+
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectMathAtan2),
99100
[tstl.LuaTarget.Luau]: builder => builder.tap(expectMathAtan2),
100101
});
101102

test/unit/expressions.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ test.each(supportedInAll)("Bitop [5.4] (%p)", input => {
9696
.expectLuaToMatchSnapshot();
9797
});
9898

99+
test.each(supportedInAll)("Bitop [5.5] (%p)", input => {
100+
util.testExpression(input)
101+
.setOptions({ luaTarget: tstl.LuaTarget.Lua55, luaLibImport: tstl.LuaLibImportKind.None })
102+
.disableSemanticCheck()
103+
.expectLuaToMatchSnapshot();
104+
});
105+
99106
test.each(unsupportedIn53And54)("Unsupported bitop 5.3 (%p)", input => {
100107
util.testExpression(input)
101108
.setOptions({ luaTarget: tstl.LuaTarget.Lua53, luaLibImport: tstl.LuaLibImportKind.None })

test/unit/loops.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ for (const testCase of [
555555
[tstl.LuaTarget.Lua52]: expectContinueGotoLabel,
556556
[tstl.LuaTarget.Lua53]: expectContinueGotoLabel,
557557
[tstl.LuaTarget.Lua54]: expectContinueGotoLabel,
558+
[tstl.LuaTarget.Lua55]: expectContinueGotoLabel,
558559
[tstl.LuaTarget.LuaJIT]: expectContinueGotoLabel,
559560
[tstl.LuaTarget.Luau]: () => expectContinueStatement,
560561
});

test/unit/spread.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe("in function call", () => {
8181
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
8282
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
8383
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
84+
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
8485
[tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
8586
}
8687
);
@@ -95,6 +96,7 @@ describe("in array literal", () => {
9596
[tstl.LuaTarget.Lua52]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
9697
[tstl.LuaTarget.Lua53]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
9798
[tstl.LuaTarget.Lua54]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
99+
[tstl.LuaTarget.Lua55]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
98100
[tstl.LuaTarget.Luau]: builder => builder.tap(expectTableUnpack).expectToMatchJsResult(),
99101
});
100102

0 commit comments

Comments
 (0)