Skip to content

Commit ac99e92

Browse files
author
Alex D
committed
fix
1 parent 989cb5a commit ac99e92

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/emitterlua.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,7 @@ export class EmitterLua {
27372737
}
27382738

27392739
private processPostfixUnaryExpression(node: ts.PostfixUnaryExpression): void {
2740+
const op = node.operator == ts.SyntaxKind.PlusPlusToken ? '+' : '-';
27402741
switch (node.operator) {
27412742
case ts.SyntaxKind.PlusPlusToken:
27422743
case ts.SyntaxKind.MinusMinusToken:
@@ -2745,16 +2746,14 @@ export class EmitterLua {
27452746
this.processExpression(node.operand);
27462747
this.functionContext.textCode.push(" = ");
27472748
this.processExpression(node.operand);
2748-
this.functionContext.textCode.push(" + 1");
2749+
this.functionContext.textCode.push(" " + op + " 1");
27492750
} else {
27502751
this.functionContext.textCode.push("(function () ");
27512752
let opIndex = parseInt(node.pos.toFixed());
27522753
if (opIndex < 0) {
27532754
opIndex = 0;
27542755
}
27552756

2756-
const op = node.operator == ts.SyntaxKind.PlusPlusToken ? '+' : '-';
2757-
27582757
this.functionContext.textCode.push("local op" + opIndex + " = (");
27592758
this.processExpression(node.operand);
27602759
this.functionContext.textCode.push(") ");

test/test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
var someArray = [9, 2, 5];
2-
for (var item of someArray) {
3-
console.log(item);
4-
}
1+
let a = 1;
2+
let count = 0;
3+
while (a) {
4+
a--;
5+
count++;
6+
}
7+
console.log(count);

0 commit comments

Comments
 (0)