dillon1000/react
Commit
Browse files Bug repro for unobserved aliased mutation w phi
I found this while working to ensure that we always lower all operands to
temporaries. This works:
```javascript
// the whole computation of x is memoized in one block, bc of the mutation after
the phi
let x;
if (cond) {
x = someObj();
} else {
x = someObj();
}
mutate(x);
```
However, if you alias either of the operands, we lose the mutation:
```javascript
let x;
if (cond) {
const y = someObj(); // OOPS this gets independently memoized
x = y;
} else {
x = someObj();
}
mutate(x);
```
The core issue is that InferMutableRanges does not take into account mutation of
phis. ~~My first thought is that we need an additional, outer fixpoint iteration
loop to flow mutation back "up" to phi operands~~
edit: there was a much easier fix, we need to alias phi operands and phi id
within the existing fixpoint iteration. See follow-up PR which fixes.Changed paths4 files
First-parent comparisoncompiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-if-else-with-alias.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-if-else-with-alias.js AddedA compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-nested-if-else-with-alias.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-nested-if-else-with-alias.js AddedPatch
Files changed
Rendering syntax-highlighted changes…