diff --git a/compiler/forget/src/HIR/SSAify.ts b/compiler/forget/src/HIR/SSAify.ts index a3965d55c0..94828557e0 100644 --- a/compiler/forget/src/HIR/SSAify.ts +++ b/compiler/forget/src/HIR/SSAify.ts @@ -174,7 +174,12 @@ export default function buildSSA(func: HIRFunction, env: Environment) { if (instr.lvalue != null) { const oldPlace = instr.lvalue.place; - const newPlace: Place = builder.definePlace(oldPlace); + let newPlace: Place; + if (oldPlace.memberPath !== null) { + newPlace = builder.getPlace(oldPlace); + } else { + newPlace = builder.definePlace(oldPlace); + } instr.lvalue.place = newPlace; } } diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md index 3626057353..d3cc631513 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md @@ -17,8 +17,8 @@ function foo() { bb0: Const mutate x$3 = Array [] Const mutate y$4 = Object { } - Reassign mutate y$5.x = read x$3 - Return freeze y$5 + Reassign mutate y$4.x = read x$3 + Return freeze y$4 ``` ## Code @@ -27,8 +27,8 @@ bb0: function foo$0() { const x$3 = []; const y$4 = {}; - y$5 = x$3; - return y$5; + y$4 = x$3; + return y$4; } ```