Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c60e514

Browse files
authoredMar 2, 2021
fix: Fix temp. local confusion in indexed assignment compilation (#1703)
1 parent 0d06d37 commit c60e514

File tree

5 files changed

+6760
-1
lines changed

5 files changed

+6760
-1
lines changed
 

‎NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ under the licensing terms detailed in LICENSE:
3333
* Piotr Oleś <piotrek.oles@gmail.com>
3434
* Saúl Cabrera <saulecabrera@gmail.com>
3535
* Chance Snow <git@chancesnow.me>
36+
* Peter Salomonsen <petersalomonsen@runbox.com>
3637

3738
Portions of this software are derived from third-party works licensed under
3839
the following terms:

‎src/compiler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5988,7 +5988,6 @@ export class Compiler extends DiagnosticEmitter {
59885988
let tempTarget = flow.getTempLocal(thisType);
59895989
let tempElement = flow.getTempLocal(elementType);
59905990
let returnType = getterInstance.signature.returnType;
5991-
flow.freeTempLocal(tempTarget);
59925991
let ret = module.block(null, [
59935992
this.makeCallDirect(setterInstance, [
59945993
module.local_tee(tempTarget.index, thisExpr, thisType.isManaged),

‎tests/compiler/issues/1699.optimized.wat

Lines changed: 2442 additions & 0 deletions
Large diffs are not rendered by default.

‎tests/compiler/issues/1699.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class MultiAssignmentTest {
2+
test: i32 = 2;
3+
}
4+
5+
function test(): void {
6+
const testinstances = new Array<MultiAssignmentTest>(3);
7+
testinstances[0] = testinstances[1] = new MultiAssignmentTest();
8+
9+
for (let n = 0; n < testinstances.length; n++) {
10+
const testinstance = new MultiAssignmentTest();
11+
if (n > 1) {
12+
testinstances[n] = testinstance;
13+
}
14+
}
15+
assert(testinstances[0] === testinstances[1]);
16+
assert(testinstances[2] !== testinstances[1]);
17+
}
18+
19+
test();

‎tests/compiler/issues/1699.untouched.wat

Lines changed: 4298 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.