Repository navigation
Commit 391b5fe
committed
fix(compiler): scan param defaults and destructuring keys in free-variable walk, and gate callback hoisting on dev/profile
Two bugs in the capture-free hook callback hoisting pass:
1. collectFreeIdentifiers walked only function bodies after collecting param
bindings, skipping default initializers and computed destructuring keys.
A callback like (s, n = props.x) => ... whose only component capture
sits in a default would appear capture-free, get lifted to module scope,
and throw ReferenceError when the default evaluated. Fix: walk each param
with the binding-augmented scope after collectBindings. Similarly, walk
destructuring VariableDeclarator id patterns (with a local scope copy
that includes the binding names) so defaults and computed keys are scanned.
2. hoistCaptureFreeHookCallbacks was gated on !hmrEnabled alone, but the
neighboring autoMemo and inlineHookMemo tiers require
!hmrEnabled && !devEnabled && !profileEnabled. The call also ran before
devEnabled/profileEnabled were computed. Fix: move the call after those
variables and extend the gate to match the sibling tiers.1 parent 0f8eb9b commit 391b5fe
1 file changed
Lines changed: 21 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2691 | 2691 | | |
2692 | 2692 | | |
2693 | 2693 | | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
2694 | 2697 | | |
2695 | 2698 | | |
2696 | 2699 | | |
| |||
2710 | 2713 | | |
2711 | 2714 | | |
2712 | 2715 | | |
2713 | | - | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2714 | 2721 | | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
2715 | 2727 | | |
2716 | 2728 | | |
2717 | 2729 | | |
| |||
5593 | 5605 | | |
5594 | 5606 | | |
5595 | 5607 | | |
5596 | | - | |
5597 | | - | |
5598 | | - | |
5599 | | - | |
5600 | 5608 | | |
5601 | 5609 | | |
5602 | 5610 | | |
| |||
5614 | 5622 | | |
5615 | 5623 | | |
5616 | 5624 | | |
| 5625 | + | |
| 5626 | + | |
| 5627 | + | |
| 5628 | + | |
| 5629 | + | |
| 5630 | + | |
| 5631 | + | |
| 5632 | + | |
5617 | 5633 | | |
5618 | 5634 | | |
5619 | 5635 | | |
| |||
0 commit comments