Commit 2b0eafe
committed
[compiler] Fix bug w functions depending on hoisted primitives (facebook#35284)
Fixes an edge case where a function expression would fail to take a
dependency if it referenced a hoisted `const` inferred as a primitive
value. We were incorrectly skipping primitve-typed operands when
determing scopes for merging in InferReactiveScopeVariables.
This was super tricky to debug, for posterity the trick is that Context
variables (StoreContext etc) are modeled just like a mutable object,
where assignment to the variable is equivalent to `object.value = ...`
and reading the variable is equivalent to `object.value` property
access. Comparing to an equivalent version of the repro case replaced
with an object and property read/writes showed that everything was
exactly right, except that InferReactiveScopeVariables wasn't merging
the scopes of the function and the context variable, which led me right
to the problematic line.
Closes facebook#35122
DiffTrain build for [2cb08e6](facebook@2cb08e6)1 parent b525738 commit 2b0eafe
File tree
23 files changed
+74
-86
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
23 files changed
+74
-86
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 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
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 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
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 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
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 | | |
| |||
30244 | 30244 | | |
30245 | 30245 | | |
30246 | 30246 | | |
30247 | | - | |
| 30247 | + | |
30248 | 30248 | | |
30249 | 30249 | | |
30250 | 30250 | | |
30251 | | - | |
| 30251 | + | |
30252 | 30252 | | |
30253 | 30253 | | |
30254 | 30254 | | |
| |||
30285 | 30285 | | |
30286 | 30286 | | |
30287 | 30287 | | |
30288 | | - | |
| 30288 | + | |
30289 | 30289 | | |
30290 | 30290 | | |
30291 | | - | |
| 30291 | + | |
30292 | 30292 | | |
30293 | 30293 | | |
30294 | 30294 | | |
| |||
30438 | 30438 | | |
30439 | 30439 | | |
30440 | 30440 | | |
30441 | | - | |
| 30441 | + | |
30442 | 30442 | | |
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 | | |
| |||
17707 | 17707 | | |
17708 | 17708 | | |
17709 | 17709 | | |
17710 | | - | |
| 17710 | + | |
17711 | 17711 | | |
17712 | 17712 | | |
17713 | 17713 | | |
17714 | 17714 | | |
17715 | 17715 | | |
17716 | 17716 | | |
17717 | | - | |
| 17717 | + | |
17718 | 17718 | | |
17719 | 17719 | | |
17720 | 17720 | | |
| |||
17736 | 17736 | | |
17737 | 17737 | | |
17738 | 17738 | | |
17739 | | - | |
| 17739 | + | |
17740 | 17740 | | |
17741 | 17741 | | |
17742 | | - | |
| 17742 | + | |
17743 | 17743 | | |
17744 | 17744 | | |
17745 | 17745 | | |
| |||
17846 | 17846 | | |
17847 | 17847 | | |
17848 | 17848 | | |
17849 | | - | |
| 17849 | + | |
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 | | |
| |||
19833 | 19833 | | |
19834 | 19834 | | |
19835 | 19835 | | |
19836 | | - | |
| 19836 | + | |
19837 | 19837 | | |
19838 | 19838 | | |
19839 | 19839 | | |
19840 | 19840 | | |
19841 | 19841 | | |
19842 | 19842 | | |
19843 | | - | |
| 19843 | + | |
19844 | 19844 | | |
19845 | 19845 | | |
19846 | 19846 | | |
| |||
19862 | 19862 | | |
19863 | 19863 | | |
19864 | 19864 | | |
19865 | | - | |
| 19865 | + | |
19866 | 19866 | | |
19867 | 19867 | | |
19868 | | - | |
| 19868 | + | |
19869 | 19869 | | |
19870 | 19870 | | |
19871 | 19871 | | |
| |||
19988 | 19988 | | |
19989 | 19989 | | |
19990 | 19990 | | |
19991 | | - | |
| 19991 | + | |
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 | | |
| |||
30306 | 30306 | | |
30307 | 30307 | | |
30308 | 30308 | | |
30309 | | - | |
| 30309 | + | |
30310 | 30310 | | |
30311 | 30311 | | |
30312 | 30312 | | |
30313 | | - | |
| 30313 | + | |
30314 | 30314 | | |
30315 | 30315 | | |
30316 | 30316 | | |
| |||
30347 | 30347 | | |
30348 | 30348 | | |
30349 | 30349 | | |
30350 | | - | |
| 30350 | + | |
30351 | 30351 | | |
30352 | 30352 | | |
30353 | | - | |
| 30353 | + | |
30354 | 30354 | | |
30355 | 30355 | | |
30356 | 30356 | | |
| |||
30816 | 30816 | | |
30817 | 30817 | | |
30818 | 30818 | | |
30819 | | - | |
| 30819 | + | |
30820 | 30820 | | |
30821 | 30821 | | |
30822 | 30822 | | |
| |||
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 | | |
| |||
17724 | 17724 | | |
17725 | 17725 | | |
17726 | 17726 | | |
17727 | | - | |
| 17727 | + | |
17728 | 17728 | | |
17729 | 17729 | | |
17730 | 17730 | | |
17731 | 17731 | | |
17732 | 17732 | | |
17733 | 17733 | | |
17734 | | - | |
| 17734 | + | |
17735 | 17735 | | |
17736 | 17736 | | |
17737 | 17737 | | |
| |||
17753 | 17753 | | |
17754 | 17754 | | |
17755 | 17755 | | |
17756 | | - | |
| 17756 | + | |
17757 | 17757 | | |
17758 | 17758 | | |
17759 | | - | |
| 17759 | + | |
17760 | 17760 | | |
17761 | 17761 | | |
17762 | 17762 | | |
| |||
18016 | 18016 | | |
18017 | 18017 | | |
18018 | 18018 | | |
18019 | | - | |
| 18019 | + | |
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 | | |
| |||
19854 | 19854 | | |
19855 | 19855 | | |
19856 | 19856 | | |
19857 | | - | |
| 19857 | + | |
19858 | 19858 | | |
19859 | 19859 | | |
19860 | 19860 | | |
19861 | 19861 | | |
19862 | 19862 | | |
19863 | 19863 | | |
19864 | | - | |
| 19864 | + | |
19865 | 19865 | | |
19866 | 19866 | | |
19867 | 19867 | | |
| |||
19883 | 19883 | | |
19884 | 19884 | | |
19885 | 19885 | | |
19886 | | - | |
| 19886 | + | |
19887 | 19887 | | |
19888 | 19888 | | |
19889 | | - | |
| 19889 | + | |
19890 | 19890 | | |
19891 | 19891 | | |
19892 | 19892 | | |
| |||
20162 | 20162 | | |
20163 | 20163 | | |
20164 | 20164 | | |
20165 | | - | |
| 20165 | + | |
20166 | 20166 | | |
20167 | 20167 | | |
20168 | 20168 | | |
| |||
0 commit comments