@samitouri / QOS-React / commits / 1a779207a7

[compiler][test fixtures] Add enablePropagateDepsInHIR to forked tests

Annotates fixtures added in #31030 with `@enablePropagateDepsInHIR` to fork behavior (and commit snapshot differences) ghstack-source-id: e423e8c42db62f1bb87562b770761be09fc8ffc6 Pull Request resolved: https://github.com/facebook/react/pull/31031

Mofei Zhang committed Sep 30, 2024 at 12:24 UTC 1a779207a7b85314e16d410b185d427702f22ebc
28 files changed +210 -124
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.expect.md
+16 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 /**
7 * props.b *does* influence `a`
8 */
@@ -29,13 +30,19 @@ export const FIXTURE_ENTRYPOINT = {
30 ## Code
31
32 ```javascript
32 -import { c as _c } from "react/compiler-runtime"; /**
33 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
34 +/**
35 * props.b *does* influence `a`
36 */
37 function Component(props) {
36 - const $ = _c(2);
38 + const $ = _c(5);
39 let a;
38 - if ($[0] !== props) {
40 + if (
41 + $[0] !== props.a ||
42 + $[1] !== props.b ||
43 + $[2] !== props.c ||
44 + $[3] !== props.d
45 + ) {
46 a = [];
47 a.push(props.a);
48 bb0: {
@@ -47,10 +54,13 @@ function Component(props) {
54 }
55
56 a.push(props.d);
50 - $[0] = props;
51 - $[1] = a;
57 + $[0] = props.a;
58 + $[1] = props.b;
59 + $[2] = props.c;
60 + $[3] = props.d;
61 + $[4] = a;
62 } else {
53 - a = $[1];
63 + a = $[4];
64 }
65 return a;
66 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 /**
3 * props.b *does* influence `a`
4 */
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.expect.md
+55 -27
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 /**
7 * props.b does *not* influence `a`
8 */
@@ -66,14 +67,15 @@ export const FIXTURE_ENTRYPOINT = {
67 ## Code
68
69 ```javascript
69 -import { c as _c } from "react/compiler-runtime"; /**
70 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
71 +/**
72 * props.b does *not* influence `a`
73 */
74 function ComponentA(props) {
73 - const $ = _c(3);
75 + const $ = _c(5);
76 let a_DEBUG;
77 let t0;
76 - if ($[0] !== props) {
78 + if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) {
79 t0 = Symbol.for("react.early_return_sentinel");
80 bb0: {
81 a_DEBUG = [];
@@ -85,12 +87,14 @@ function ComponentA(props) {
87
88 a_DEBUG.push(props.d);
89 }
88 - $[0] = props;
89 - $[1] = a_DEBUG;
90 - $[2] = t0;
90 + $[0] = props.a;
91 + $[1] = props.b;
92 + $[2] = props.d;
93 + $[3] = a_DEBUG;
94 + $[4] = t0;
95 } else {
92 - a_DEBUG = $[1];
93 - t0 = $[2];
96 + a_DEBUG = $[3];
97 + t0 = $[4];
98 }
99 if (t0 !== Symbol.for("react.early_return_sentinel")) {
100 return t0;
@@ -102,9 +106,14 @@ function ComponentA(props) {
106 * props.b *does* influence `a`
107 */
108 function ComponentB(props) {
105 - const $ = _c(2);
109 + const $ = _c(5);
110 let a;
107 - if ($[0] !== props) {
111 + if (
112 + $[0] !== props.a ||
113 + $[1] !== props.b ||
114 + $[2] !== props.c ||
115 + $[3] !== props.d
116 + ) {
117 a = [];
118 a.push(props.a);
119 if (props.b) {
@@ -112,10 +121,13 @@ function ComponentB(props) {
121 }
122
123 a.push(props.d);
115 - $[0] = props;
116 - $[1] = a;
124 + $[0] = props.a;
125 + $[1] = props.b;
126 + $[2] = props.c;
127 + $[3] = props.d;
128 + $[4] = a;
129 } else {
118 - a = $[1];
130 + a = $[4];
131 }
132 return a;
133 }
@@ -124,10 +136,15 @@ function ComponentB(props) {
136 * props.b *does* influence `a`, but only in a way that is never observable
137 */
138 function ComponentC(props) {
127 - const $ = _c(3);
139 + const $ = _c(6);
140 let a;
141 let t0;
130 - if ($[0] !== props) {
142 + if (
143 + $[0] !== props.a ||
144 + $[1] !== props.b ||
145 + $[2] !== props.c ||
146 + $[3] !== props.d
147 + ) {
148 t0 = Symbol.for("react.early_return_sentinel");
149 bb0: {
150 a = [];
@@ -140,12 +157,15 @@ function ComponentC(props) {
157
158 a.push(props.d);
159 }
143 - $[0] = props;
144 - $[1] = a;
145 - $[2] = t0;
160 + $[0] = props.a;
161 + $[1] = props.b;
162 + $[2] = props.c;
163 + $[3] = props.d;
164 + $[4] = a;
165 + $[5] = t0;
166 } else {
147 - a = $[1];
148 - t0 = $[2];
167 + a = $[4];
168 + t0 = $[5];
169 }
170 if (t0 !== Symbol.for("react.early_return_sentinel")) {
171 return t0;
@@ -157,10 +177,15 @@ function ComponentC(props) {
177 * props.b *does* influence `a`
178 */
179 function ComponentD(props) {
160 - const $ = _c(3);
180 + const $ = _c(6);
181 let a;
182 let t0;
163 - if ($[0] !== props) {
183 + if (
184 + $[0] !== props.a ||
185 + $[1] !== props.b ||
186 + $[2] !== props.c ||
187 + $[3] !== props.d
188 + ) {
189 t0 = Symbol.for("react.early_return_sentinel");
190 bb0: {
191 a = [];
@@ -173,12 +198,15 @@ function ComponentD(props) {
198
199 a.push(props.d);
200 }
176 - $[0] = props;
177 - $[1] = a;
178 - $[2] = t0;
201 + $[0] = props.a;
202 + $[1] = props.b;
203 + $[2] = props.c;
204 + $[3] = props.d;
205 + $[4] = a;
206 + $[5] = t0;
207 } else {
180 - a = $[1];
181 - t0 = $[2];
208 + a = $[4];
209 + t0 = $[5];
210 }
211 if (t0 !== Symbol.for("react.early_return_sentinel")) {
212 return t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 /**
3 * props.b does *not* influence `a`
4 */
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.expect.md
+16 -11
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function ComponentA(props) {
7 const a = [];
8 const b = [];
@@ -34,11 +35,11 @@ function mayMutate() {}
35 ## Code
36
37 ```javascript
37 -import { c as _c } from "react/compiler-runtime";
38 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
39 function ComponentA(props) {
39 - const $ = _c(2);
40 + const $ = _c(4);
41 let t0;
41 - if ($[0] !== props) {
42 + if ($[0] !== props.p0 || $[1] !== props.p1 || $[2] !== props.p2) {
43 const a = [];
44 const b = [];
45 if (b) {
@@ -49,18 +50,20 @@ function ComponentA(props) {
50 }
51
52 t0 = <Foo a={a} b={b} />;
52 - $[0] = props;
53 - $[1] = t0;
53 + $[0] = props.p0;
54 + $[1] = props.p1;
55 + $[2] = props.p2;
56 + $[3] = t0;
57 } else {
55 - t0 = $[1];
58 + t0 = $[3];
59 }
60 return t0;
61 }
62
63 function ComponentB(props) {
61 - const $ = _c(2);
64 + const $ = _c(4);
65 let t0;
63 - if ($[0] !== props) {
66 + if ($[0] !== props.p0 || $[1] !== props.p1 || $[2] !== props.p2) {
67 const a = [];
68 const b = [];
69 if (mayMutate(b)) {
@@ -71,10 +74,12 @@ function ComponentB(props) {
74 }
75
76 t0 = <Foo a={a} b={b} />;
74 - $[0] = props;
75 - $[1] = t0;
77 + $[0] = props.p0;
78 + $[1] = props.p1;
79 + $[2] = props.p2;
80 + $[3] = t0;
81 } else {
77 - t0 = $[1];
82 + t0 = $[3];
83 }
84 return t0;
85 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function ComponentA(props) {
3 const a = [];
4 const b = [];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-nested-early-return-within-reactive-scope.expect.md
+16 -13
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function Component(props) {
7 let x = [];
8 if (props.cond) {
@@ -29,11 +30,11 @@ export const FIXTURE_ENTRYPOINT = {
30 ## Code
31
32 ```javascript
32 -import { c as _c } from "react/compiler-runtime";
33 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
34 function Component(props) {
34 - const $ = _c(5);
35 + const $ = _c(7);
36 let t0;
36 - if ($[0] !== props) {
37 + if ($[0] !== props.cond || $[1] !== props.a || $[2] !== props.b) {
38 t0 = Symbol.for("react.early_return_sentinel");
39 bb0: {
40 const x = [];
@@ -41,12 +42,12 @@ function Component(props) {
42 x.push(props.a);
43 if (props.b) {
44 let t1;
44 - if ($[2] !== props.b) {
45 + if ($[4] !== props.b) {
46 t1 = [props.b];
46 - $[2] = props.b;
47 - $[3] = t1;
47 + $[4] = props.b;
48 + $[5] = t1;
49 } else {
49 - t1 = $[3];
50 + t1 = $[5];
51 }
52 const y = t1;
53 x.push(y);
@@ -58,20 +59,22 @@ function Component(props) {
59 break bb0;
60 } else {
61 let t1;
61 - if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
62 + if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
63 t1 = foo();
63 - $[4] = t1;
64 + $[6] = t1;
65 } else {
65 - t1 = $[4];
66 + t1 = $[6];
67 }
68 t0 = t1;
69 break bb0;
70 }
71 }
71 - $[0] = props;
72 - $[1] = t0;
72 + $[0] = props.cond;
73 + $[1] = props.a;
74 + $[2] = props.b;
75 + $[3] = t0;
76 } else {
74 - t0 = $[1];
77 + t0 = $[3];
78 }
79 if (t0 !== Symbol.for("react.early_return_sentinel")) {
80 return t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-nested-early-return-within-reactive-scope.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function Component(props) {
3 let x = [];
4 if (props.cond) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-within-reactive-scope.expect.md
+13 -10
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 import {makeArray} from 'shared-runtime';
7
8 function Component(props) {
@@ -41,13 +42,13 @@ export const FIXTURE_ENTRYPOINT = {
42 ## Code
43
44 ```javascript
44 -import { c as _c } from "react/compiler-runtime";
45 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
46 import { makeArray } from "shared-runtime";
47
48 function Component(props) {
48 - const $ = _c(4);
49 + const $ = _c(6);
50 let t0;
50 - if ($[0] !== props) {
51 + if ($[0] !== props.cond || $[1] !== props.a || $[2] !== props.b) {
52 t0 = Symbol.for("react.early_return_sentinel");
53 bb0: {
54 const x = [];
@@ -57,21 +58,23 @@ function Component(props) {
58 break bb0;
59 } else {
60 let t1;
60 - if ($[2] !== props.b) {
61 + if ($[4] !== props.b) {
62 t1 = makeArray(props.b);
62 - $[2] = props.b;
63 - $[3] = t1;
63 + $[4] = props.b;
64 + $[5] = t1;
65 } else {
65 - t1 = $[3];
66 + t1 = $[5];
67 }
68 t0 = t1;
69 break bb0;
70 }
71 }
71 - $[0] = props;
72 - $[1] = t0;
72 + $[0] = props.cond;
73 + $[1] = props.a;
74 + $[2] = props.b;
75 + $[3] = t0;
76 } else {
74 - t0 = $[1];
77 + t0 = $[3];
78 }
79 if (t0 !== Symbol.for("react.early_return_sentinel")) {
80 return t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-within-reactive-scope.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 import {makeArray} from 'shared-runtime';
3
4 function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-call-chain-in-optional.expect.md
+8 -7
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function useFoo(props: {value: {x: string; y: string} | null}) {
7 const value = props.value;
8 return createArray(value?.x, value?.y)?.join(', ');
@@ -22,13 +23,13 @@ export const FIXTURE_ENTRYPONT = {
23 ## Error
24
25 ```
25 - 1 | function useFoo(props: {value: {x: string; y: string} | null}) {
26 - 2 | const value = props.value;
27 -> 3 | return createArray(value?.x, value?.y)?.join(', ');
28 - | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for optional test block (3:3)
29 - 4 | }
30 - 5 |
31 - 6 | function createArray<T>(...args: Array<T>): Array<T> {
26 + 2 | function useFoo(props: {value: {x: string; y: string} | null}) {
27 + 3 | const value = props.value;
28 +> 4 | return createArray(value?.x, value?.y)?.join(', ');
29 + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for optional test block (4:4)
30 + 5 | }
31 + 6 |
32 + 7 | function createArray<T>(...args: Array<T>): Array<T> {
33 ```
34
35
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-call-chain-in-optional.ts
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function useFoo(props: {value: {x: string; y: string} | null}) {
3 const value = props.value;
4 return createArray(value?.x, value?.y)?.join(', ');
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/iife-return-modified-later-phi.expect.md
+8 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function Component(props) {
7 const items = (() => {
8 if (props.cond) {
@@ -24,11 +25,11 @@ export const FIXTURE_ENTRYPOINT = {
25 ## Code
26
27 ```javascript
27 -import { c as _c } from "react/compiler-runtime";
28 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
29 function Component(props) {
29 - const $ = _c(2);
30 + const $ = _c(3);
31 let items;
31 - if ($[0] !== props) {
32 + if ($[0] !== props.cond || $[1] !== props.a) {
33 let t0;
34 if (props.cond) {
35 t0 = [];
@@ -38,10 +39,11 @@ function Component(props) {
39 items = t0;
40
41 items?.push(props.a);
41 - $[0] = props;
42 - $[1] = items;
42 + $[0] = props.cond;
43 + $[1] = props.a;
44 + $[2] = items;
45 } else {
44 - items = $[1];
46 + items = $[2];
47 }
48 return items;
49 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/iife-return-modified-later-phi.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function Component(props) {
3 const items = (() => {
4 if (props.cond) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/object-mutated-in-consequent-alternate-both-return.expect.md
+8 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 import {makeObject_Primitives} from 'shared-runtime';
7
8 function Component(props) {
@@ -25,13 +26,13 @@ export const FIXTURE_ENTRYPOINT = {
26 ## Code
27
28 ```javascript
28 -import { c as _c } from "react/compiler-runtime";
29 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
30 import { makeObject_Primitives } from "shared-runtime";
31
32 function Component(props) {
32 - const $ = _c(2);
33 + const $ = _c(3);
34 let t0;
34 - if ($[0] !== props) {
35 + if ($[0] !== props.cond || $[1] !== props.value) {
36 t0 = Symbol.for("react.early_return_sentinel");
37 bb0: {
38 const object = makeObject_Primitives();
@@ -45,10 +46,11 @@ function Component(props) {
46 break bb0;
47 }
48 }
48 - $[0] = props;
49 - $[1] = t0;
49 + $[0] = props.cond;
50 + $[1] = props.value;
51 + $[2] = t0;
52 } else {
51 - t0 = $[1];
53 + t0 = $[2];
54 }
55 if (t0 !== Symbol.for("react.early_return_sentinel")) {
56 return t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/object-mutated-in-consequent-alternate-both-return.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 import {makeObject_Primitives} from 'shared-runtime';
3
4 function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/partial-early-return-within-reactive-scope.expect.md
+14 -11
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function Component(props) {
7 let x = [];
8 let y = null;
@@ -28,12 +29,12 @@ export const FIXTURE_ENTRYPOINT = {
29 ## Code
30
31 ```javascript
31 -import { c as _c } from "react/compiler-runtime";
32 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
33 function Component(props) {
33 - const $ = _c(4);
34 + const $ = _c(6);
35 let y;
36 let t0;
36 - if ($[0] !== props) {
37 + if ($[0] !== props.cond || $[1] !== props.a || $[2] !== props.b) {
38 t0 = Symbol.for("react.early_return_sentinel");
39 bb0: {
40 const x = [];
@@ -43,11 +44,11 @@ function Component(props) {
44 break bb0;
45 } else {
46 let t1;
46 - if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47 + if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
48 t1 = foo();
48 - $[3] = t1;
49 + $[5] = t1;
50 } else {
50 - t1 = $[3];
51 + t1 = $[5];
52 }
53 y = t1;
54 if (props.b) {
@@ -56,12 +57,14 @@ function Component(props) {
57 }
58 }
59 }
59 - $[0] = props;
60 - $[1] = y;
61 - $[2] = t0;
60 + $[0] = props.cond;
61 + $[1] = props.a;
62 + $[2] = props.b;
63 + $[3] = y;
64 + $[4] = t0;
65 } else {
63 - y = $[1];
64 - t0 = $[2];
66 + y = $[3];
67 + t0 = $[4];
68 }
69 if (t0 !== Symbol.for("react.early_return_sentinel")) {
70 return t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/partial-early-return-within-reactive-scope.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function Component(props) {
3 let x = [];
4 let y = null;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push-consecutive-phis.expect.md
+15 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 import {makeArray} from 'shared-runtime';
7
8 function Component(props) {
@@ -45,11 +46,11 @@ export const FIXTURE_ENTRYPOINT = {
46 ## Code
47
48 ```javascript
48 -import { c as _c } from "react/compiler-runtime";
49 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
50 import { makeArray } from "shared-runtime";
51
52 function Component(props) {
52 - const $ = _c(3);
53 + const $ = _c(6);
54 let t0;
55 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
56 t0 = {};
@@ -59,7 +60,12 @@ function Component(props) {
60 }
61 const x = t0;
62 let t1;
62 - if ($[1] !== props) {
63 + if (
64 + $[1] !== props.cond ||
65 + $[2] !== props.cond2 ||
66 + $[3] !== props.value ||
67 + $[4] !== props.value2
68 + ) {
69 let y;
70 if (props.cond) {
71 if (props.cond2) {
@@ -74,10 +80,13 @@ function Component(props) {
80 y.push(x);
81
82 t1 = [x, y];
77 - $[1] = props;
78 - $[2] = t1;
83 + $[1] = props.cond;
84 + $[2] = props.cond2;
85 + $[3] = props.value;
86 + $[4] = props.value2;
87 + $[5] = t1;
88 } else {
80 - t1 = $[2];
89 + t1 = $[5];
90 }
91 return t1;
92 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push-consecutive-phis.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 import {makeArray} from 'shared-runtime';
3
4 function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push.expect.md
+8 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function Component(props) {
7 const x = {};
8 let y;
@@ -34,9 +35,9 @@ export const FIXTURE_ENTRYPOINT = {
35 ## Code
36
37 ```javascript
37 -import { c as _c } from "react/compiler-runtime";
38 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
39 function Component(props) {
39 - const $ = _c(3);
40 + const $ = _c(4);
41 let t0;
42 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
43 t0 = {};
@@ -46,7 +47,7 @@ function Component(props) {
47 }
48 const x = t0;
49 let t1;
49 - if ($[1] !== props) {
50 + if ($[1] !== props.cond || $[2] !== props.value) {
51 let y;
52 if (props.cond) {
53 y = [props.value];
@@ -57,10 +58,11 @@ function Component(props) {
58 y.push(x);
59
60 t1 = [x, y];
60 - $[1] = props;
61 - $[2] = t1;
61 + $[1] = props.cond;
62 + $[2] = props.value;
63 + $[3] = t1;
64 } else {
63 - t1 = $[2];
65 + t1 = $[3];
66 }
67 return t1;
68 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function Component(props) {
3 const x = {};
4 let y;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-property-store.expect.md
+8 -7
@@ -2,7 +2,7 @@
2 ## Input
3
4 ```javascript
5 -// @debug
5 +// @debug @enablePropagateDepsInHIR
6 function Component(props) {
7 const x = {};
8 let y;
@@ -30,9 +30,9 @@ export const FIXTURE_ENTRYPOINT = {
30 ## Code
31
32 ```javascript
33 -import { c as _c } from "react/compiler-runtime"; // @debug
33 +import { c as _c } from "react/compiler-runtime"; // @debug @enablePropagateDepsInHIR
34 function Component(props) {
35 - const $ = _c(3);
35 + const $ = _c(4);
36 let t0;
37 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
38 t0 = {};
@@ -42,7 +42,7 @@ function Component(props) {
42 }
43 const x = t0;
44 let t1;
45 - if ($[1] !== props) {
45 + if ($[1] !== props.cond || $[2] !== props.a) {
46 let y;
47 if (props.cond) {
48 y = {};
@@ -53,10 +53,11 @@ function Component(props) {
53 y.x = x;
54
55 t1 = [x, y];
56 - $[1] = props;
57 - $[2] = t1;
56 + $[1] = props.cond;
57 + $[2] = props.a;
58 + $[3] = t1;
59 } else {
59 - t1 = $[2];
60 + t1 = $[3];
61 }
62 return t1;
63 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-property-store.js
+1 -1
@@ -1,4 +1,4 @@
1 -// @debug
1 +// @debug @enablePropagateDepsInHIR
2 function Component(props) {
3 const x = {};
4 let y;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reactive-dependencies-non-optional-properties-inside-optional-chain.expect.md
+2 -1
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 function Component(props) {
7 return props.post.feedback.comments?.edges?.map(render);
8 }
@@ -11,7 +12,7 @@ function Component(props) {
12 ## Code
13
14 ```javascript
14 -import { c as _c } from "react/compiler-runtime";
15 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
16 function Component(props) {
17 const $ = _c(2);
18 let t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reactive-dependencies-non-optional-properties-inside-optional-chain.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 function Component(props) {
3 return props.post.feedback.comments?.edges?.map(render);
4 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/ssa-renaming-unconditional-with-mutation.expect.md
+9 -6
@@ -2,6 +2,7 @@
2 ## Input
3
4 ```javascript
5 +// @enablePropagateDepsInHIR
6 import {mutate} from 'shared-runtime';
7
8 function useFoo(props) {
@@ -35,13 +36,13 @@ export const FIXTURE_ENTRYPOINT = {
36 ## Code
37
38 ```javascript
38 -import { c as _c } from "react/compiler-runtime";
39 +import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
40 import { mutate } from "shared-runtime";
41
42 function useFoo(props) {
42 - const $ = _c(2);
43 + const $ = _c(4);
44 let x;
44 - if ($[0] !== props) {
45 + if ($[0] !== props.bar || $[1] !== props.cond || $[2] !== props.foo) {
46 x = [];
47 x.push(props.bar);
48 if (props.cond) {
@@ -53,10 +54,12 @@ function useFoo(props) {
54 }
55
56 mutate(x);
56 - $[0] = props;
57 - $[1] = x;
57 + $[0] = props.bar;
58 + $[1] = props.cond;
59 + $[2] = props.foo;
60 + $[3] = x;
61 } else {
59 - x = $[1];
62 + x = $[3];
63 }
64 return x;
65 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/ssa-renaming-unconditional-with-mutation.js
+1
@@ -1,3 +1,4 @@
1 +// @enablePropagateDepsInHIR
2 import {mutate} from 'shared-runtime';
3
4 function useFoo(props) {