Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/LuaTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,10 @@ export class LuaTransformer {
);
}

if (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) {
if (
(ts.isPropertyAccessExpression(expression.left) && !tsHelper.hasSetAccessor(expression.left, this.checker))
|| ts.isElementAccessExpression(expression.left)
) {
// Left is property/element access: cache result while maintaining order of evaluation
// (function(o, i, v) o[i] = v; return v end)(${objExpression}, ${indexExpression}, ${right})
const objParameter = tstl.createIdentifier("o");
Expand Down
1 change: 1 addition & 0 deletions test/unit/expressions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export class ExpressionTests {
@TestCase("inst.field | 3", 8 | 3)
@TestCase("inst.field << 3", 8 << 3)
@TestCase("inst.field >> 1", 8 >> 1)
@TestCase("inst.field = 3", 7)
@TestCase(`"abc" + inst.field`, "abc8")
@Test("Get accessor expression")
public getAccessorBinary(expression: string, expected: any): void {
Expand Down