dillon1000/react
Commit
Browse files Adjust scope ranges to block boundaries
Visits the HIR as a tree and updates mutable ranges to ensure their range end is
aligned with the block in which the scope is declared:
```javascript
function foo(cond, a) {
⌵ original scope
⌵ expanded scope
const x = []; ⌝ ⌝
if (cond) { ⎮ ⎮
... ⎮ ⎮
x.push(a); ⌟ ⎮
... ⎮
} ⎮
... ⌟
}
```
The implementation tracks the block in which each scope "starts" (first
instruction with an operand in that scope), and then finds the first instruction
at that block (or a parent) which is after the scope's end.Changed paths27 files
First-parent comparisoncompiler/forget/src/HIR/HIRTreeVisitor.ts ModifiedM compiler/forget/src/HIR/InferReactiveScopes.ts ModifiedM compiler/forget/src/HIR/Pipeline.ts ModifiedM compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md ModifiedA compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.js AddedM compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md ModifiedA compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/inverted-if.js AddedM compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/switch.expect.md ModifiedM compiler/forget/src/__tests__/hir-test.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…