Commit d3f70d8
committed
[compiler] Validate against mutable functions being frozen
This revisits a validation I built a while ago, trying to make it more strict this time to ensure that it's high-signal.
We detect function expressions which are *known* mutable — they definitely can modify a variable defined outside of the function expression itself (modulo control flow). This uses types to look for known Store and Mutate effects only, and disregards mutations of effects. Any such function passed to a location with a Freeze effect is reported as a validation error.
This is behind a flag and disabled by default. If folks agree this makes sense to revisit, i'll test out internally and we can consider enabling by default.
ghstack-source-id: 075a731
Pull Request resolved: facebook#33079
DiffTrain build for [0db8db1](facebook@0db8db1)1 parent 7c39333 commit d3f70d8
File tree
35 files changed
+3174
-95
lines changed- compiled
- eslint-plugin-react-hooks
- facebook-www
35 files changed
+3174
-95
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1538 | 1538 | | |
1539 | 1539 | | |
1540 | 1540 | | |
1541 | | - | |
| 1541 | + | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1538 | 1538 | | |
1539 | 1539 | | |
1540 | 1540 | | |
1541 | | - | |
| 1541 | + | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | | - | |
| 639 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | | - | |
| 639 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19014 | 19014 | | |
19015 | 19015 | | |
19016 | 19016 | | |
19017 | | - | |
| 19017 | + | |
19018 | 19018 | | |
19019 | 19019 | | |
19020 | | - | |
| 19020 | + | |
19021 | 19021 | | |
19022 | 19022 | | |
19023 | 19023 | | |
| |||
19051 | 19051 | | |
19052 | 19052 | | |
19053 | 19053 | | |
19054 | | - | |
| 19054 | + | |
19055 | 19055 | | |
19056 | 19056 | | |
19057 | 19057 | | |
| |||
0 commit comments