Commit d3ae620
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: #33079
DiffTrain build for [0db8db1](0db8db1)1 parent 31e777b commit d3ae620
File tree
26 files changed
+531
-91
lines changed- compiled-rn
- facebook-fbsource/xplat/js
- RKJSModules/vendor/react
- react-dom/cjs
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
- implementations
- tools/eslint-plugin-react-hooks
- cjs
26 files changed
+531
-91
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
26650 | 26650 | | |
26651 | 26651 | | |
26652 | 26652 | | |
26653 | | - | |
| 26653 | + | |
26654 | 26654 | | |
26655 | 26655 | | |
26656 | 26656 | | |
26657 | | - | |
| 26657 | + | |
26658 | 26658 | | |
26659 | 26659 | | |
26660 | 26660 | | |
| |||
26691 | 26691 | | |
26692 | 26692 | | |
26693 | 26693 | | |
26694 | | - | |
| 26694 | + | |
26695 | 26695 | | |
26696 | 26696 | | |
26697 | | - | |
| 26697 | + | |
26698 | 26698 | | |
26699 | 26699 | | |
26700 | 26700 | | |
| |||
26838 | 26838 | | |
26839 | 26839 | | |
26840 | 26840 | | |
26841 | | - | |
| 26841 | + | |
26842 | 26842 | | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
16748 | 16748 | | |
16749 | 16749 | | |
16750 | 16750 | | |
16751 | | - | |
| 16751 | + | |
16752 | 16752 | | |
16753 | 16753 | | |
16754 | 16754 | | |
16755 | 16755 | | |
16756 | 16756 | | |
16757 | 16757 | | |
16758 | | - | |
| 16758 | + | |
16759 | 16759 | | |
16760 | 16760 | | |
16761 | 16761 | | |
| |||
16777 | 16777 | | |
16778 | 16778 | | |
16779 | 16779 | | |
16780 | | - | |
| 16780 | + | |
16781 | 16781 | | |
16782 | 16782 | | |
16783 | | - | |
| 16783 | + | |
16784 | 16784 | | |
16785 | 16785 | | |
16786 | 16786 | | |
| |||
16884 | 16884 | | |
16885 | 16885 | | |
16886 | 16886 | | |
16887 | | - | |
| 16887 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17457 | 17457 | | |
17458 | 17458 | | |
17459 | 17459 | | |
17460 | | - | |
| 17460 | + | |
17461 | 17461 | | |
17462 | 17462 | | |
17463 | 17463 | | |
17464 | 17464 | | |
17465 | 17465 | | |
17466 | 17466 | | |
17467 | | - | |
| 17467 | + | |
17468 | 17468 | | |
17469 | 17469 | | |
17470 | 17470 | | |
| |||
17486 | 17486 | | |
17487 | 17487 | | |
17488 | 17488 | | |
17489 | | - | |
| 17489 | + | |
17490 | 17490 | | |
17491 | 17491 | | |
17492 | | - | |
| 17492 | + | |
17493 | 17493 | | |
17494 | 17494 | | |
17495 | 17495 | | |
| |||
17608 | 17608 | | |
17609 | 17609 | | |
17610 | 17610 | | |
17611 | | - | |
| 17611 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
26711 | 26711 | | |
26712 | 26712 | | |
26713 | 26713 | | |
26714 | | - | |
| 26714 | + | |
26715 | 26715 | | |
26716 | 26716 | | |
26717 | 26717 | | |
26718 | | - | |
| 26718 | + | |
26719 | 26719 | | |
26720 | 26720 | | |
26721 | 26721 | | |
| |||
26752 | 26752 | | |
26753 | 26753 | | |
26754 | 26754 | | |
26755 | | - | |
| 26755 | + | |
26756 | 26756 | | |
26757 | 26757 | | |
26758 | | - | |
| 26758 | + | |
26759 | 26759 | | |
26760 | 26760 | | |
26761 | 26761 | | |
| |||
27215 | 27215 | | |
27216 | 27216 | | |
27217 | 27217 | | |
27218 | | - | |
| 27218 | + | |
27219 | 27219 | | |
27220 | 27220 | | |
27221 | 27221 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
16759 | 16759 | | |
16760 | 16760 | | |
16761 | 16761 | | |
16762 | | - | |
| 16762 | + | |
16763 | 16763 | | |
16764 | 16764 | | |
16765 | 16765 | | |
16766 | 16766 | | |
16767 | 16767 | | |
16768 | 16768 | | |
16769 | | - | |
| 16769 | + | |
16770 | 16770 | | |
16771 | 16771 | | |
16772 | 16772 | | |
| |||
16788 | 16788 | | |
16789 | 16789 | | |
16790 | 16790 | | |
16791 | | - | |
| 16791 | + | |
16792 | 16792 | | |
16793 | 16793 | | |
16794 | | - | |
| 16794 | + | |
16795 | 16795 | | |
16796 | 16796 | | |
16797 | 16797 | | |
| |||
17049 | 17049 | | |
17050 | 17050 | | |
17051 | 17051 | | |
17052 | | - | |
| 17052 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17472 | 17472 | | |
17473 | 17473 | | |
17474 | 17474 | | |
17475 | | - | |
| 17475 | + | |
17476 | 17476 | | |
17477 | 17477 | | |
17478 | 17478 | | |
17479 | 17479 | | |
17480 | 17480 | | |
17481 | 17481 | | |
17482 | | - | |
| 17482 | + | |
17483 | 17483 | | |
17484 | 17484 | | |
17485 | 17485 | | |
| |||
17501 | 17501 | | |
17502 | 17502 | | |
17503 | 17503 | | |
17504 | | - | |
| 17504 | + | |
17505 | 17505 | | |
17506 | 17506 | | |
17507 | | - | |
| 17507 | + | |
17508 | 17508 | | |
17509 | 17509 | | |
17510 | 17510 | | |
| |||
17777 | 17777 | | |
17778 | 17778 | | |
17779 | 17779 | | |
17780 | | - | |
| 17780 | + | |
17781 | 17781 | | |
17782 | 17782 | | |
17783 | 17783 | | |
| |||
0 commit comments