Skip to content

Commit 093d8fa

Browse files
committed
Disallow usage of goto and label in Lua 5.1
1 parent ee4130c commit 093d8fa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/targets/Transpiler.51.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ import { TSHelper as tsHelper } from "../TSHelper";
44
import * as ts from "typescript";
55

66
export class LuaTranspiler51 extends LuaTranspiler {
7+
public transpileLoopBody(
8+
node: ts.WhileStatement
9+
| ts.DoStatement
10+
| ts.ForStatement
11+
| ts.ForOfStatement
12+
| ts.ForInStatement
13+
): string {
14+
this.loopStack.push(this.genVarCounter);
15+
this.genVarCounter++;
16+
let result = this.indent + "do\n";
17+
this.pushIndent();
18+
result += this.transpileStatement(node.statement);
19+
this.popIndent();
20+
result += this.indent + "end\n";
21+
return result;
22+
}
23+
24+
public transpileContinue(): string {
25+
throw new TranspileError(
26+
"Unsupported continue statement, " +
27+
"continue is not supported in Lua ${this.options.luaTarget}.",
28+
null
29+
);
30+
}
731
}

0 commit comments

Comments
 (0)