Skip to content

Commit 456ffdb

Browse files
committed
Simplify expression - 1 + 1
1 parent 2606809 commit 456ffdb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/LuaTransformer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5094,6 +5094,14 @@ export class LuaTransformer {
50945094
}
50955095

50965096
if (tstl.isBinaryExpression(expression)) {
5097+
if (
5098+
expression.operator === tstl.SyntaxKind.SubtractionOperator &&
5099+
tstl.isNumericLiteral(expression.right) &&
5100+
expression.right.value === 1
5101+
) {
5102+
return expression.left;
5103+
}
5104+
50975105
expression = tstl.createParenthesizedExpression(expression);
50985106
}
50995107

0 commit comments

Comments
 (0)