From fb66480bfab2eeac98f7cdb79fc91e8b9d8293ed Mon Sep 17 00:00:00 2001 From: Osyris Date: Tue, 10 Jul 2018 14:22:45 -0700 Subject: [PATCH 1/2] Fixed bug where table.unpack was called in Lua5.1 --- .vscode/settings.json | 15 +++++++++++++++ src/Transpiler.ts | 6 +++++- src/targets/Transpiler.52.ts | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..8e6af2eb4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "files.trimTrailingWhitespace": false, + "editor.formatOnSave": false, + "[typescript]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "[json]": { + "editor.formatOnSave": false + }, + "editor.detectIndentation": true, + "tslint.autoFixOnSave": true +} \ No newline at end of file diff --git a/src/Transpiler.ts b/src/Transpiler.ts index 395f1bcc3..fcf4cdbe8 100644 --- a/src/Transpiler.ts +++ b/src/Transpiler.ts @@ -1175,7 +1175,7 @@ export abstract class LuaTranspiler { if (tsHelper.isTupleReturnCall(node.initializer, this.checker)) { return `local ${vars}=${value}\n`; } else { - return `local ${vars}=table.unpack(${value})\n`; + return `local ${vars}=${this.getUnpackFunction()}(${value})\n`; } } else { throw new TranspileError( @@ -1531,4 +1531,8 @@ export abstract class LuaTranspiler { return result; } + + protected getUnpackFunction() { + return "unpack"; + } } diff --git a/src/targets/Transpiler.52.ts b/src/targets/Transpiler.52.ts index 07b48e50a..4bb938edd 100644 --- a/src/targets/Transpiler.52.ts +++ b/src/targets/Transpiler.52.ts @@ -53,4 +53,9 @@ export class LuaTranspiler52 extends LuaTranspiler51 { return `bit32.arshift(${lhs},${rhs})`; } } + + /** @override */ + protected getUnpackFunction() { + return "table.unpack"; + } } From 977ce59b49b302aa99a942235ad7ff9e97d5651c Mon Sep 17 00:00:00 2001 From: Osyris Date: Wed, 11 Jul 2018 14:57:44 -0700 Subject: [PATCH 2/2] Delete settings.json --- .vscode/settings.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8e6af2eb4..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "files.trimTrailingWhitespace": false, - "editor.formatOnSave": false, - "[typescript]": { - "editor.formatOnSave": false - }, - "[javascript]": { - "editor.formatOnSave": false - }, - "[json]": { - "editor.formatOnSave": false - }, - "editor.detectIndentation": true, - "tslint.autoFixOnSave": true -} \ No newline at end of file