@samitouri / QOS-React-2 / commits / 80cb7a9925

Revert "[compiler] Fix VariableDeclarator source location (#35129)" (#35346)

This broke main.

Sebastian Markbåge committed Dec 11, 2025 at 15:27 UTC 80cb7a99255fb030bf11cb8a8298d94f379563c7
174 files changed +398 -459
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts
-2
@@ -4026,7 +4026,6 @@ function lowerAssignment(
4026 pattern: {
4027 kind: 'ArrayPattern',
4028 items,
4029 - loc: lvalue.node.loc ?? GeneratedSource,
4029 },
4030 },
4031 value,
@@ -4204,7 +4203,6 @@ function lowerAssignment(
4203 pattern: {
4204 kind: 'ObjectPattern',
4205 properties,
4207 - loc: lvalue.node.loc ?? GeneratedSource,
4206 },
4207 },
4208 value,
compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
-2
@@ -694,13 +694,11 @@ export type SpreadPattern = {
694 export type ArrayPattern = {
695 kind: 'ArrayPattern';
696 items: Array<Place | SpreadPattern | Hole>;
697 - loc: SourceLocation;
697 };
698
699 export type ObjectPattern = {
700 kind: 'ObjectPattern';
701 properties: Array<ObjectProperty | SpreadPattern>;
703 - loc: SourceLocation;
702 };
703
704 export type ObjectPropertyKey =
compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineJsx.ts
-1
@@ -515,7 +515,6 @@ function emitDestructureProps(
515 pattern: {
516 kind: 'ObjectPattern',
517 properties,
518 - loc: GeneratedSource,
518 },
519 kind: InstructionKind.Let,
520 },
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts
+8 -38
@@ -702,7 +702,7 @@ function codegenReactiveScope(
702 outputComments.push(name.name);
703 if (!cx.hasDeclared(identifier)) {
704 statements.push(
705 - t.variableDeclaration('let', [createVariableDeclarator(name, null)]),
705 + t.variableDeclaration('let', [t.variableDeclarator(name)]),
706 );
707 }
708 cacheLoads.push({name, index, value: wrapCacheDep(cx, name)});
@@ -1387,7 +1387,7 @@ function codegenInstructionNullable(
1387 suggestions: null,
1388 });
1389 return createVariableDeclaration(instr.loc, 'const', [
1390 - createVariableDeclarator(codegenLValue(cx, lvalue), value),
1390 + t.variableDeclarator(codegenLValue(cx, lvalue), value),
1391 ]);
1392 }
1393 case InstructionKind.Function: {
@@ -1451,7 +1451,7 @@ function codegenInstructionNullable(
1451 suggestions: null,
1452 });
1453 return createVariableDeclaration(instr.loc, 'let', [
1454 - createVariableDeclarator(codegenLValue(cx, lvalue), value),
1454 + t.variableDeclarator(codegenLValue(cx, lvalue), value),
1455 ]);
1456 }
1457 case InstructionKind.Reassign: {
@@ -1691,9 +1691,6 @@ function withLoc<T extends (...args: Array<any>) => t.Node>(
1691 };
1692 }
1693
1694 -const createIdentifier = withLoc(t.identifier);
1695 -const createArrayPattern = withLoc(t.arrayPattern);
1696 -const createObjectPattern = withLoc(t.objectPattern);
1694 const createBinaryExpression = withLoc(t.binaryExpression);
1695 const createExpressionStatement = withLoc(t.expressionStatement);
1696 const _createLabelledStatement = withLoc(t.labeledStatement);
@@ -1725,31 +1722,6 @@ const createTryStatement = withLoc(t.tryStatement);
1722 const createBreakStatement = withLoc(t.breakStatement);
1723 const createContinueStatement = withLoc(t.continueStatement);
1724
1728 -function createVariableDeclarator(
1729 - id: t.LVal,
1730 - init?: t.Expression | null,
1731 -): t.VariableDeclarator {
1732 - const node = t.variableDeclarator(id, init);
1733 -
1734 - /*
1735 - * The variable declarator location is not preserved in HIR, however, we can use the
1736 - * start location of the id and the end location of the init to recreate the
1737 - * exact original variable declarator location.
1738 - *
1739 - * Or if init is null, we likely have a declaration without an initializer, so we can use the id.loc.end as the end location.
1740 - */
1741 - if (id.loc && (init === null || init?.loc)) {
1742 - node.loc = {
1743 - start: id.loc.start,
1744 - end: init?.loc?.end ?? id.loc.end,
1745 - filename: id.loc.filename,
1746 - identifierName: undefined,
1747 - };
1748 - }
1749 -
1750 - return node;
1751 -}
1752 -
1725 function createHookGuard(
1726 guard: ExternalFunction,
1727 context: ProgramContext,
@@ -1857,7 +1829,7 @@ function codegenInstruction(
1829 );
1830 } else {
1831 return createVariableDeclaration(instr.loc, 'const', [
1860 - createVariableDeclarator(
1832 + t.variableDeclarator(
1833 convertIdentifier(instr.lvalue.identifier),
1834 expressionValue,
1835 ),
@@ -2784,7 +2756,7 @@ function codegenArrayPattern(
2756 ): t.ArrayPattern {
2757 const hasHoles = !pattern.items.every(e => e.kind !== 'Hole');
2758 if (hasHoles) {
2787 - const result = createArrayPattern(pattern.loc, []);
2759 + const result = t.arrayPattern([]);
2760 /*
2761 * Older versions of babel have a validation bug fixed by
2762 * https://github.com/babel/babel/pull/10917
@@ -2805,8 +2777,7 @@ function codegenArrayPattern(
2777 }
2778 return result;
2779 } else {
2808 - return createArrayPattern(
2809 - pattern.loc,
2780 + return t.arrayPattern(
2781 pattern.items.map(item => {
2782 if (item.kind === 'Hole') {
2783 return null;
@@ -2826,8 +2797,7 @@ function codegenLValue(
2797 return codegenArrayPattern(cx, pattern);
2798 }
2799 case 'ObjectPattern': {
2829 - return createObjectPattern(
2830 - pattern.loc,
2800 + return t.objectPattern(
2801 pattern.properties.map(property => {
2802 if (property.kind === 'ObjectProperty') {
2803 const key = codegenObjectPropertyKey(cx, property.key);
@@ -2946,7 +2916,7 @@ function convertIdentifier(identifier: Identifier): t.Identifier {
2916 suggestions: null,
2917 },
2918 );
2949 - return createIdentifier(identifier.loc, identifier.name.value);
2919 + return t.identifier(identifier.name.value);
2920 }
2921
2922 function compareScopeDependency(
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts
+26 -116
@@ -27,11 +27,7 @@ import {Result} from '../Utils/Result';
27
28 /**
29 * Some common node types that are important for coverage tracking.
30 - * Based on istanbul-lib-instrument + some other common nodes we expect to be present in the generated AST.
31 - *
32 - * Note: For VariableDeclaration, VariableDeclarator, and Identifier, we enforce stricter validation
33 - * that requires both the source location AND node type to match in the generated AST. This ensures
34 - * that variable declarations maintain their structural integrity through compilation.
30 + * Based on istanbul-lib-instrument
31 */
32 const IMPORTANT_INSTRUMENTED_TYPES = new Set([
33 'ArrowFunctionExpression',
@@ -58,14 +54,6 @@ const IMPORTANT_INSTRUMENTED_TYPES = new Set([
54 'LabeledStatement',
55 'ConditionalExpression',
56 'LogicalExpression',
61 -
62 - /**
63 - * Note: these aren't important for coverage tracking,
64 - * but we still want to track them to ensure we aren't regressing them when
65 - * we fix the source location tracking for other nodes.
66 - */
67 - 'VariableDeclaration',
68 - 'Identifier',
57 ]);
58
59 /**
@@ -126,13 +114,10 @@ export function validateSourceLocations(
114 ): Result<void, CompilerError> {
115 const errors = new CompilerError();
116
129 - /*
130 - * Step 1: Collect important locations from the original source
131 - * Note: Multiple node types can share the same location (e.g. VariableDeclarator and Identifier)
132 - */
117 + // Step 1: Collect important locations from the original source
118 const importantOriginalLocations = new Map<
119 string,
135 - {loc: t.SourceLocation; nodeTypes: Set<string>}
120 + {loc: t.SourceLocation; nodeType: string}
121 >();
122
123 func.traverse({
@@ -152,31 +137,20 @@ export function validateSourceLocations(
137 // Collect the location if it exists
138 if (node.loc) {
139 const key = locationKey(node.loc);
155 - const existing = importantOriginalLocations.get(key);
156 - if (existing) {
157 - existing.nodeTypes.add(node.type);
158 - } else {
159 - importantOriginalLocations.set(key, {
160 - loc: node.loc,
161 - nodeTypes: new Set([node.type]),
162 - });
163 - }
140 + importantOriginalLocations.set(key, {
141 + loc: node.loc,
142 + nodeType: node.type,
143 + });
144 }
145 },
146 });
147
168 - // Step 2: Collect all locations from the generated AST with their node types
169 - const generatedLocations = new Map<string, Set<string>>();
148 + // Step 2: Collect all locations from the generated AST
149 + const generatedLocations = new Set<string>();
150
151 function collectGeneratedLocations(node: t.Node): void {
152 if (node.loc) {
173 - const key = locationKey(node.loc);
174 - const nodeTypes = generatedLocations.get(key);
175 - if (nodeTypes) {
176 - nodeTypes.add(node.type);
177 - } else {
178 - generatedLocations.set(key, new Set([node.type]));
179 - }
153 + generatedLocations.add(locationKey(node.loc));
154 }
155
156 // Use Babel's VISITOR_KEYS to traverse only actual node properties
@@ -209,86 +183,22 @@ export function validateSourceLocations(
183 collectGeneratedLocations(outlined.fn.body);
184 }
185
212 - /*
213 - * Step 3: Validate that all important locations are preserved
214 - * For certain node types, also validate that the node type matches
215 - */
216 - const strictNodeTypes = new Set([
217 - 'VariableDeclaration',
218 - 'VariableDeclarator',
219 - 'Identifier',
220 - ]);
221 -
222 - const reportMissingLocation = (
223 - loc: t.SourceLocation,
224 - nodeType: string,
225 - ): void => {
226 - errors.pushDiagnostic(
227 - CompilerDiagnostic.create({
228 - category: ErrorCategory.Todo,
229 - reason: 'Important source location missing in generated code',
230 - description:
231 - `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
232 - `to fail to track this code properly, resulting in inaccurate coverage reports.`,
233 - }).withDetails({
234 - kind: 'error',
235 - loc,
236 - message: null,
237 - }),
238 - );
239 - };
240 -
241 - const reportWrongNodeType = (
242 - loc: t.SourceLocation,
243 - expectedType: string,
244 - actualTypes: Set<string>,
245 - ): void => {
246 - errors.pushDiagnostic(
247 - CompilerDiagnostic.create({
248 - category: ErrorCategory.Todo,
249 - reason:
250 - 'Important source location has wrong node type in generated code',
251 - description:
252 - `Source location for ${expectedType} exists in the generated output but with wrong node type(s): ${Array.from(actualTypes).join(', ')}. ` +
253 - `This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports.`,
254 - }).withDetails({
255 - kind: 'error',
256 - loc,
257 - message: null,
258 - }),
259 - );
260 - };
261 -
262 - for (const [key, {loc, nodeTypes}] of importantOriginalLocations) {
263 - const generatedNodeTypes = generatedLocations.get(key);
264 -
265 - if (!generatedNodeTypes) {
266 - // Location is completely missing
267 - reportMissingLocation(loc, Array.from(nodeTypes).join(', '));
268 - } else {
269 - // Location exists, check each node type
270 - for (const nodeType of nodeTypes) {
271 - if (
272 - strictNodeTypes.has(nodeType) &&
273 - !generatedNodeTypes.has(nodeType)
274 - ) {
275 - /*
276 - * For strict node types, the specific node type must be present
277 - * Check if any generated node type is also an important original node type
278 - */
279 - const hasValidNodeType = Array.from(generatedNodeTypes).some(
280 - genType => nodeTypes.has(genType),
281 - );
282 -
283 - if (hasValidNodeType) {
284 - // At least one generated node type is valid (also in original), so this is just missing
285 - reportMissingLocation(loc, nodeType);
286 - } else {
287 - // None of the generated node types are in original - this is wrong node type
288 - reportWrongNodeType(loc, nodeType, generatedNodeTypes);
289 - }
290 - }
291 - }
186 + // Step 3: Validate that all important locations are preserved
187 + for (const [key, {loc, nodeType}] of importantOriginalLocations) {
188 + if (!generatedLocations.has(key)) {
189 + errors.pushDiagnostic(
190 + CompilerDiagnostic.create({
191 + category: ErrorCategory.Todo,
192 + reason: 'Important source location missing in generated code',
193 + description:
194 + `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
195 + `to fail to track this code properly, resulting in inaccurate coverage reports.`,
196 + }).withDetails({
197 + kind: 'error',
198 + loc,
199 + message: null,
200 + }),
201 + );
202 }
203 }
204
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/alias-capture-in-method-receiver-and-mutate.expect.md
+2
@@ -35,8 +35,10 @@ function Component() {
35 let t0;
36 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37 const a = makeObject_Primitives();
38 +
39 const x = [];
40 x.push(a);
41 +
42 mutate(x);
43 t0 = [x, a];
44 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/alias-capture-in-method-receiver.expect.md
+1
@@ -33,6 +33,7 @@ function Component() {
33 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
34 const x = [];
35 x.push(a);
36 +
37 t1 = [x, a];
38 $[1] = t1;
39 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-fn-expr.expect.md
+4
@@ -85,10 +85,14 @@ function Component(t0) {
85 let t1;
86 if ($[0] !== prop) {
87 const obj = shallowCopy(prop);
88 +
89 const aliasedObj = identity(obj);
90 +
91 const getId = () => obj.id;
92 +
93 mutate(aliasedObj);
94 setPropertyByKey(aliasedObj, "id", prop.id + 1);
95 +
96 t1 = <Stringify getId={getId} shouldInvokeFns={true} />;
97 $[0] = prop;
98 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-truncated-dep.expect.md
+3
@@ -181,9 +181,12 @@ function Component(t0) {
181 if ($[0] !== prop) {
182 const obj = shallowCopy(prop);
183 const aliasedObj = identity(obj);
184 +
185 const id = [obj.id];
186 +
187 mutate(aliasedObj);
188 setPropertyByKey(aliasedObj, "id", prop.id + 1);
189 +
190 t1 = <Stringify id={id} />;
191 $[0] = prop;
192 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/align-scopes-within-nested-valueblock-in-array.expect.md
+1
@@ -54,6 +54,7 @@ function Foo(t0) {
54 let t1;
55 if ($[0] !== cond1 || $[1] !== cond2) {
56 const arr = makeArray({ a: 2 }, 2, []);
57 +
58 t1 = cond1 ? (
59 <>
60 <div>{identity("foo")}</div>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-mutating-ref-in-callback-passed-to-jsx-indirect.expect.md
+1
@@ -49,6 +49,7 @@ function Component() {
49 ref.current = "";
50 }
51 };
52 +
53 t0 = () => {
54 setRef();
55 };
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-mutating-ref-property-in-callback-passed-to-jsx-indirect.expect.md
+1
@@ -49,6 +49,7 @@ function Component() {
49 ref.current.value = "";
50 }
51 };
52 +
53 t0 = () => {
54 setRef();
55 };
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-event-handler-wrapper.expect.md
+1
@@ -74,6 +74,7 @@ function Component() {
74 console.log(ref.current.value);
75 }
76 };
77 +
78 t0 = (
79 <>
80 <input ref={ref} />
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-type-cast-in-render.expect.md
+1
@@ -36,6 +36,7 @@ function useArrayOfRef() {
36 const callback = (value) => {
37 ref.current = value;
38 };
39 +
40 t0 = [callback];
41 $[0] = t0;
42 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-at-closure.expect.md
+1
@@ -35,6 +35,7 @@ function Component(props) {
35 const arr = [...bar(props)];
36 return arr.at(x);
37 };
38 +
39 t1 = fn();
40 $[2] = props;
41 $[3] = x;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-spread-mutable-iterator.expect.md
+1
@@ -61,6 +61,7 @@ function useBar(t0) {
61 if ($[0] !== arg) {
62 const s = new Set([1, 5, 4]);
63 const mutableIterator = s.values();
64 +
65 t1 = [arg, ...mutableIterator];
66 $[0] = arg;
67 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call.expect.md
+1
@@ -28,6 +28,7 @@ function Component(props) {
28 const a = [];
29 const b = {};
30 foo(a, b);
31 +
32 foo(b);
33 t0 = <div a={a} b={b} />;
34 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capture-ref-for-later-mutation.expect.md
+1
@@ -45,6 +45,7 @@ function useKeyCommand() {
45 const nextPosition = direction === "left" ? addOne(position) : position;
46 currentPosition.current = nextPosition;
47 };
48 +
49 const moveLeft = { handler: handleKey("left") };
50 const moveRight = { handler: handleKey("right") };
51 t0 = [moveLeft, moveRight];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md
+1
@@ -45,6 +45,7 @@ function Component(t0) {
45 z.a = 2;
46 mutate(y.b);
47 };
48 +
49 x();
50 t1 = [y, z];
51 $[0] = a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-emit-make-read-only.expect.md
+1
@@ -29,6 +29,7 @@ function MyComponentName(props) {
29 const x = {};
30 foo(x, props.a);
31 foo(x, props.b);
32 +
33 y = [];
34 y.push(x);
35 $[0] = props.a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-inline-iife-reassign.expect.md
+1
@@ -34,6 +34,7 @@ function useTest() {
34 let t0;
35 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36 let w = {};
37 +
38 const t1 = (w = 42);
39 const t2 = w;
40
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-inline-iife-storeprop.expect.md
+1
@@ -34,6 +34,7 @@ function useTest() {
34 let t0;
35 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36 const w = {};
37 +
38 const t1 = (w.x = 42);
39 const t2 = w.x;
40
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md
+4
@@ -44,9 +44,11 @@ function ComponentA(props) {
44 if (b) {
45 a.push(props.p0);
46 }
47 +
48 if (props.p1) {
49 b.push(props.p2);
50 }
51 +
52 t0 = <Foo a={a} b={b} />;
53 $[0] = props.p0;
54 $[1] = props.p1;
@@ -67,9 +69,11 @@ function ComponentB(props) {
69 if (mayMutate(b)) {
70 a.push(props.p0);
71 }
72 +
73 if (props.p1) {
74 b.push(props.p2);
75 }
76 +
77 t0 = <Foo a={a} b={b} />;
78 $[0] = props.p0;
79 $[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constructor.expect.md
+1
@@ -28,6 +28,7 @@ function Component(props) {
28 const a = [];
29 const b = {};
30 new Foo(a, b);
31 +
32 new Foo(b);
33 t0 = <div a={a} b={b} />;
34 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/context-variable-reassigned-outside-of-lambda.expect.md
+1
@@ -34,6 +34,7 @@ function Component(props) {
34 const callback = () => {
35 console.log(x);
36 };
37 +
38 x = {};
39 t0 = <Stringify callback={callback} shouldInvokeFns={true} />;
40 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md
+3
@@ -75,6 +75,7 @@ function Component(props) {
75 let t0;
76 if ($[0] !== post) {
77 const allUrls = [];
78 +
79 const { media: t1, comments: t2, urls: t3 } = post;
80 const media = t1 === undefined ? null : t1;
81 let t4;
@@ -101,6 +102,7 @@ function Component(props) {
102 if (!comments.length) {
103 return;
104 }
105 +
106 console.log(comments.length);
107 };
108 $[6] = comments.length;
@@ -109,6 +111,7 @@ function Component(props) {
111 t6 = $[7];
112 }
113 const onClick = t6;
114 +
115 allUrls.push(...urls);
116 t0 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
117 $[0] = post;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md
+3
@@ -53,6 +53,7 @@ function Component(props) {
53 let t0;
54 if ($[0] !== post) {
55 const allUrls = [];
56 +
57 const { media, comments, urls } = post;
58 let t1;
59 if ($[2] !== comments.length) {
@@ -60,6 +61,7 @@ function Component(props) {
61 if (!comments.length) {
62 return;
63 }
64 +
65 console.log(comments.length);
66 };
67 $[2] = comments.length;
@@ -68,6 +70,7 @@ function Component(props) {
70 t1 = $[3];
71 }
72 const onClick = t1;
73 +
74 allUrls.push(...urls);
75 t0 = <Media media={media} onClick={onClick} />;
76 $[0] = post;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md
+1
@@ -57,6 +57,7 @@ function Component(t0) {
57 let y;
58 if ($[0] !== a || $[1] !== b || $[2] !== c) {
59 x = [];
60 +
61 if (a) {
62 let t1;
63 if ($[5] !== b) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/derived-state-conditionally-in-effect.expect.md
+1
@@ -46,6 +46,7 @@ function Component(t0) {
46 setLocalValue("disabled");
47 }
48 };
49 +
50 t2 = [value, enabled];
51 $[0] = enabled;
52 $[1] = value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/function-expression-mutation-edge-case.expect.md
+3
@@ -65,14 +65,17 @@ function Component() {
65 if ($[2] !== bar || $[3] !== foo) {
66 t2 = () => {
67 let isChanged = false;
68 +
69 const newData = foo.map((val) => {
70 bar.someMethod(val);
71 isChanged = true;
72 });
73 +
74 if (isChanged) {
75 setFoo(newData);
76 }
77 };
78 +
79 t3 = [foo, bar];
80 $[2] = bar;
81 $[3] = foo;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/ref-conditional-in-effect-no-error.expect.md
+1
@@ -50,6 +50,7 @@ export default function Component(t0) {
50 setLocal(test + test);
51 }
52 };
53 +
54 t2 = [test];
55 $[0] = test;
56 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.expect.md
+112 -282
@@ -10,28 +10,14 @@ function Component({prop1, prop2}) {
10 const y = x * 2;
11 const arr = [x, y];
12 const obj = {x, y};
13 - let destA, destB;
14 - if (y > 5) {
15 - [destA, destB] = arr;
16 - }
17 -
13 const [a, b] = arr;
14 const {x: c, y: d} = obj;
20 - let sound;
21 -
22 - if (y > 10) {
23 - sound = 'woof';
24 - } else {
25 - sound = 'meow';
26 - }
15
16 useEffect(() => {
17 if (a > 10) {
18 console.log(a);
31 - console.log(sound);
32 - console.log(destA, destB);
19 }
34 - }, [a, sound, destA, destB]);
20 + }, [a]);
21
22 const foo = useCallback(() => {
23 return a + b;
@@ -52,343 +38,187 @@ function Component({prop1, prop2}) {
38 ## Error
39
40 ```
55 -Found 25 errors:
41 +Found 13 errors:
42
43 Todo: Important source location missing in generated code
44
59 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
45 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
46
61 -error.todo-missing-source-locations.ts:4:9
62 - 2 | import {useEffect, useCallback} from 'react';
47 +error.todo-missing-source-locations.ts:5:8
48 3 |
64 -> 4 | function Component({prop1, prop2}) {
65 - | ^^^^^^^^^
66 - 5 | const x = prop1 + prop2;
49 + 4 | function Component({prop1, prop2}) {
50 +> 5 | const x = prop1 + prop2;
51 + | ^^^^^^^^^^^^^^^^^
52 6 | const y = x * 2;
53 7 | const arr = [x, y];
54 + 8 | const obj = {x, y};
55
56 Todo: Important source location missing in generated code
57
72 -Source location for VariableDeclaration is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
73 -
74 -error.todo-missing-source-locations.ts:9:2
75 - 7 | const arr = [x, y];
76 - 8 | const obj = {x, y};
77 -> 9 | let destA, destB;
78 - | ^^^^^^^^^^^^^^^^^
79 - 10 | if (y > 5) {
80 - 11 | [destA, destB] = arr;
81 - 12 | }
82 -
83 -Todo: Important source location missing in generated code
58 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
59
85 -Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
86 -
87 -error.todo-missing-source-locations.ts:11:4
88 - 9 | let destA, destB;
89 - 10 | if (y > 5) {
90 -> 11 | [destA, destB] = arr;
91 - | ^^^^^^^^^^^^^^^^^^^^^
92 - 12 | }
93 - 13 |
94 - 14 | const [a, b] = arr;
95 -
96 -Todo: Important source location missing in generated code
97 -
98 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
99 -
100 -error.todo-missing-source-locations.ts:15:9
101 - 13 |
102 - 14 | const [a, b] = arr;
103 -> 15 | const {x: c, y: d} = obj;
104 - | ^
105 - 16 | let sound;
106 - 17 |
107 - 18 | if (y > 10) {
60 +error.todo-missing-source-locations.ts:6:8
61 + 4 | function Component({prop1, prop2}) {
62 + 5 | const x = prop1 + prop2;
63 +> 6 | const y = x * 2;
64 + | ^^^^^^^^^
65 + 7 | const arr = [x, y];
66 + 8 | const obj = {x, y};
67 + 9 | const [a, b] = arr;
68
69 Todo: Important source location missing in generated code
70
111 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
71 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
72
113 -error.todo-missing-source-locations.ts:15:15
114 - 13 |
115 - 14 | const [a, b] = arr;
116 -> 15 | const {x: c, y: d} = obj;
117 - | ^
118 - 16 | let sound;
119 - 17 |
120 - 18 | if (y > 10) {
73 +error.todo-missing-source-locations.ts:7:8
74 + 5 | const x = prop1 + prop2;
75 + 6 | const y = x * 2;
76 +> 7 | const arr = [x, y];
77 + | ^^^^^^^^^^^^
78 + 8 | const obj = {x, y};
79 + 9 | const [a, b] = arr;
80 + 10 | const {x: c, y: d} = obj;
81
82 Todo: Important source location missing in generated code
83
124 -Source location for VariableDeclaration is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
84 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
85
126 -error.todo-missing-source-locations.ts:16:2
127 - 14 | const [a, b] = arr;
128 - 15 | const {x: c, y: d} = obj;
129 -> 16 | let sound;
130 - | ^^^^^^^^^^
131 - 17 |
132 - 18 | if (y > 10) {
133 - 19 | sound = 'woof';
86 +error.todo-missing-source-locations.ts:8:8
87 + 6 | const y = x * 2;
88 + 7 | const arr = [x, y];
89 +> 8 | const obj = {x, y};
90 + | ^^^^^^^^^^^^
91 + 9 | const [a, b] = arr;
92 + 10 | const {x: c, y: d} = obj;
93 + 11 |
94
95 Todo: Important source location missing in generated code
96
137 -Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
138 -
139 -error.todo-missing-source-locations.ts:19:4
140 - 17 |
141 - 18 | if (y > 10) {
142 -> 19 | sound = 'woof';
143 - | ^^^^^^^^^^^^^^^
144 - 20 | } else {
145 - 21 | sound = 'meow';
146 - 22 | }
147 -
148 -Todo: Important source location has wrong node type in generated code
97 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
98
150 -Source location for Identifier exists in the generated output but with wrong node type(s): ExpressionStatement. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
151 -
152 -error.todo-missing-source-locations.ts:19:4
153 - 17 |
154 - 18 | if (y > 10) {
155 -> 19 | sound = 'woof';
156 - | ^^^^^
157 - 20 | } else {
158 - 21 | sound = 'meow';
159 - 22 | }
99 +error.todo-missing-source-locations.ts:9:8
100 + 7 | const arr = [x, y];
101 + 8 | const obj = {x, y};
102 +> 9 | const [a, b] = arr;
103 + | ^^^^^^^^^^^^
104 + 10 | const {x: c, y: d} = obj;
105 + 11 |
106 + 12 | useEffect(() => {
107
108 Todo: Important source location missing in generated code
109
163 -Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
164 -
165 -error.todo-missing-source-locations.ts:21:4
166 - 19 | sound = 'woof';
167 - 20 | } else {
168 -> 21 | sound = 'meow';
169 - | ^^^^^^^^^^^^^^^
170 - 22 | }
171 - 23 |
172 - 24 | useEffect(() => {
110 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
111
174 -Todo: Important source location has wrong node type in generated code
175 -
176 -Source location for Identifier exists in the generated output but with wrong node type(s): ExpressionStatement. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
177 -
178 -error.todo-missing-source-locations.ts:21:4
179 - 19 | sound = 'woof';
180 - 20 | } else {
181 -> 21 | sound = 'meow';
182 - | ^^^^^
183 - 22 | }
184 - 23 |
185 - 24 | useEffect(() => {
112 +error.todo-missing-source-locations.ts:10:8
113 + 8 | const obj = {x, y};
114 + 9 | const [a, b] = arr;
115 +> 10 | const {x: c, y: d} = obj;
116 + | ^^^^^^^^^^^^^^^^^^
117 + 11 |
118 + 12 | useEffect(() => {
119 + 13 | if (a > 10) {
120
121 Todo: Important source location missing in generated code
122
123 Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
124
191 -error.todo-missing-source-locations.ts:24:2
192 - 22 | }
193 - 23 |
194 -> 24 | useEffect(() => {
125 +error.todo-missing-source-locations.ts:12:2
126 + 10 | const {x: c, y: d} = obj;
127 + 11 |
128 +> 12 | useEffect(() => {
129 | ^^^^^^^^^^^^^^^^^
196 -> 25 | if (a > 10) {
197 - | ^^^^^^^^^^^^^^^^^
198 -> 26 | console.log(a);
199 - | ^^^^^^^^^^^^^^^^^
200 -> 27 | console.log(sound);
130 +> 13 | if (a > 10) {
131 | ^^^^^^^^^^^^^^^^^
202 -> 28 | console.log(destA, destB);
132 +> 14 | console.log(a);
133 | ^^^^^^^^^^^^^^^^^
204 -> 29 | }
134 +> 15 | }
135 | ^^^^^^^^^^^^^^^^^
206 -> 30 | }, [a, sound, destA, destB]);
207 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208 - 31 |
209 - 32 | const foo = useCallback(() => {
210 - 33 | return a + b;
136 +> 16 | }, [a]);
137 + | ^^^^^^^^^^^
138 + 17 |
139 + 18 | const foo = useCallback(() => {
140 + 19 | return a + b;
141
142 Todo: Important source location missing in generated code
143
144 Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
145
216 -error.todo-missing-source-locations.ts:26:6
217 - 24 | useEffect(() => {
218 - 25 | if (a > 10) {
219 -> 26 | console.log(a);
146 +error.todo-missing-source-locations.ts:14:6
147 + 12 | useEffect(() => {
148 + 13 | if (a > 10) {
149 +> 14 | console.log(a);
150 | ^^^^^^^^^^^^^^^
221 - 27 | console.log(sound);
222 - 28 | console.log(destA, destB);
223 - 29 | }
224 -
225 -Todo: Important source location missing in generated code
226 -
227 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
228 -
229 -error.todo-missing-source-locations.ts:26:14
230 - 24 | useEffect(() => {
231 - 25 | if (a > 10) {
232 -> 26 | console.log(a);
233 - | ^^^
234 - 27 | console.log(sound);
235 - 28 | console.log(destA, destB);
236 - 29 | }
237 -
238 -Todo: Important source location missing in generated code
239 -
240 -Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
241 -
242 -error.todo-missing-source-locations.ts:27:6
243 - 25 | if (a > 10) {
244 - 26 | console.log(a);
245 -> 27 | console.log(sound);
246 - | ^^^^^^^^^^^^^^^^^^^
247 - 28 | console.log(destA, destB);
248 - 29 | }
249 - 30 | }, [a, sound, destA, destB]);
250 -
251 -Todo: Important source location missing in generated code
252 -
253 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
254 -
255 -error.todo-missing-source-locations.ts:27:14
256 - 25 | if (a > 10) {
257 - 26 | console.log(a);
258 -> 27 | console.log(sound);
259 - | ^^^
260 - 28 | console.log(destA, destB);
261 - 29 | }
262 - 30 | }, [a, sound, destA, destB]);
263 -
264 -Todo: Important source location missing in generated code
265 -
266 -Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
267 -
268 -error.todo-missing-source-locations.ts:28:6
269 - 26 | console.log(a);
270 - 27 | console.log(sound);
271 -> 28 | console.log(destA, destB);
272 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^
273 - 29 | }
274 - 30 | }, [a, sound, destA, destB]);
275 - 31 |
276 -
277 -Todo: Important source location missing in generated code
278 -
279 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
280 -
281 -error.todo-missing-source-locations.ts:28:14
282 - 26 | console.log(a);
283 - 27 | console.log(sound);
284 -> 28 | console.log(destA, destB);
285 - | ^^^
286 - 29 | }
287 - 30 | }, [a, sound, destA, destB]);
288 - 31 |
151 + 15 | }
152 + 16 | }, [a]);
153 + 17 |
154
155 Todo: Important source location missing in generated code
156
292 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
157 +Source location for VariableDeclarator is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
158
294 -error.todo-missing-source-locations.ts:32:14
295 - 30 | }, [a, sound, destA, destB]);
296 - 31 |
297 -> 32 | const foo = useCallback(() => {
298 - | ^^^^^^^^^^^
299 - 33 | return a + b;
300 - 34 | }, [a, b]);
301 - 35 |
159 +error.todo-missing-source-locations.ts:18:8
160 + 16 | }, [a]);
161 + 17 |
162 +> 18 | const foo = useCallback(() => {
163 + | ^^^^^^^^^^^^^^^^^^^^^^^^^
164 +> 19 | return a + b;
165 + | ^^^^^^^^^^^^^^^^^
166 +> 20 | }, [a, b]);
167 + | ^^^^^^^^^^^^^
168 + 21 |
169 + 22 | function bar() {
170 + 23 | return (c + d) * 2;
171
172 Todo: Important source location missing in generated code
173
174 Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
175
307 -error.todo-missing-source-locations.ts:33:4
308 - 31 |
309 - 32 | const foo = useCallback(() => {
310 -> 33 | return a + b;
176 +error.todo-missing-source-locations.ts:19:4
177 + 17 |
178 + 18 | const foo = useCallback(() => {
179 +> 19 | return a + b;
180 | ^^^^^^^^^^^^^
312 - 34 | }, [a, b]);
313 - 35 |
314 - 36 | function bar() {
315 -
316 -Todo: Important source location missing in generated code
317 -
318 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
319 -
320 -error.todo-missing-source-locations.ts:34:6
321 - 32 | const foo = useCallback(() => {
322 - 33 | return a + b;
323 -> 34 | }, [a, b]);
324 - | ^
325 - 35 |
326 - 36 | function bar() {
327 - 37 | return (c + d) * 2;
328 -
329 -Todo: Important source location missing in generated code
330 -
331 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
332 -
333 -error.todo-missing-source-locations.ts:34:9
334 - 32 | const foo = useCallback(() => {
335 - 33 | return a + b;
336 -> 34 | }, [a, b]);
337 - | ^
338 - 35 |
339 - 36 | function bar() {
340 - 37 | return (c + d) * 2;
181 + 20 | }, [a, b]);
182 + 21 |
183 + 22 | function bar() {
184
185 Todo: Important source location missing in generated code
186
187 Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
188
346 -error.todo-missing-source-locations.ts:37:4
347 - 35 |
348 - 36 | function bar() {
349 -> 37 | return (c + d) * 2;
189 +error.todo-missing-source-locations.ts:23:4
190 + 21 |
191 + 22 | function bar() {
192 +> 23 | return (c + d) * 2;
193 | ^^^^^^^^^^^^^^^^^^^
351 - 38 | }
352 - 39 |
353 - 40 | console.log('Hello, world!');
194 + 24 | }
195 + 25 |
196 + 26 | console.log('Hello, world!');
197
198 Todo: Important source location missing in generated code
199
200 Source location for ExpressionStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
201
359 -error.todo-missing-source-locations.ts:40:2
360 - 38 | }
361 - 39 |
362 -> 40 | console.log('Hello, world!');
202 +error.todo-missing-source-locations.ts:26:2
203 + 24 | }
204 + 25 |
205 +> 26 | console.log('Hello, world!');
206 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
364 - 41 |
365 - 42 | return [y, foo, bar];
366 - 43 | }
367 -
368 -Todo: Important source location missing in generated code
369 -
370 -Source location for Identifier is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
371 -
372 -error.todo-missing-source-locations.ts:40:10
373 - 38 | }
374 - 39 |
375 -> 40 | console.log('Hello, world!');
376 - | ^^^
377 - 41 |
378 - 42 | return [y, foo, bar];
379 - 43 | }
207 + 27 |
208 + 28 | return [y, foo, bar];
209 + 29 | }
210
211 Todo: Important source location missing in generated code
212
213 Source location for ReturnStatement is missing in the generated output. This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports..
214
385 -error.todo-missing-source-locations.ts:42:2
386 - 40 | console.log('Hello, world!');
387 - 41 |
388 -> 42 | return [y, foo, bar];
215 +error.todo-missing-source-locations.ts:28:2
216 + 26 | console.log('Hello, world!');
217 + 27 |
218 +> 28 | return [y, foo, bar];
219 | ^^^^^^^^^^^^^^^^^^^^^
390 - 43 | }
391 - 44 |
220 + 29 | }
221 + 30 |
222 ```
223
224
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.js
+1 -15
@@ -6,28 +6,14 @@ function Component({prop1, prop2}) {
6 const y = x * 2;
7 const arr = [x, y];
8 const obj = {x, y};
9 - let destA, destB;
10 - if (y > 5) {
11 - [destA, destB] = arr;
12 - }
13 -
9 const [a, b] = arr;
10 const {x: c, y: d} = obj;
16 - let sound;
17 -
18 - if (y > 10) {
19 - sound = 'woof';
20 - } else {
21 - sound = 'meow';
22 - }
11
12 useEffect(() => {
13 if (a > 10) {
14 console.log(a);
27 - console.log(sound);
28 - console.log(destA, destB);
15 }
30 - }, [a, sound, destA, destB]);
16 + }, [a]);
17
18 const foo = useCallback(() => {
19 return a + b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md
+1
@@ -44,6 +44,7 @@ function Component(props) {
44 let t0;
45 if ($[0] !== props.a) {
46 const a = [props.a];
47 +
48 t0 = [a];
49 $[0] = props.a;
50 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-newline.expect.md
+2
@@ -40,11 +40,13 @@ function Component(props) {
40 [
41 fbt._param(
42 "a really long description that got split into multiple lines",
43 +
44 props.name,
45 ),
46 ],
47 { hk: "1euPUp" },
48 );
49 +
50 t0 = element.toString();
51 $[0] = props.name;
52 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-quotes.expect.md
+8 -1
@@ -32,9 +32,16 @@ function Component(props) {
32 if ($[0] !== props.name) {
33 const element = fbt._(
34 'Hello {"user" name}',
35 - [fbt._param('"user" name', props.name)],
35 + [
36 + fbt._param(
37 + '"user" name',
38 +
39 + props.name,
40 + ),
41 + ],
42 { hk: "S0vMe" },
43 );
44 +
45 t0 = element.toString();
46 $[0] = props.name;
47 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-param-with-unicode.expect.md
+8 -1
@@ -32,9 +32,16 @@ function Component(props) {
32 if ($[0] !== props.name) {
33 const element = fbt._(
34 "Hello {user name ☺}",
35 - [fbt._param("user name \u263A", props.name)],
35 + [
36 + fbt._param(
37 + "user name \u263A",
38 +
39 + props.name,
40 + ),
41 + ],
42 { hk: "1En1lp" },
43 );
44 +
45 t0 = element.toString();
46 $[0] = props.name;
47 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-to-string.expect.md
+8 -1
@@ -32,9 +32,16 @@ function Component(props) {
32 if ($[0] !== props.name) {
33 const element = fbt._(
34 "Hello {user name}",
35 - [fbt._param("user name", props.name)],
35 + [
36 + fbt._param(
37 + "user name",
38 +
39 + props.name,
40 + ),
41 + ],
42 { hk: "2zEDKF" },
43 );
44 +
45 t0 = element.toString();
46 $[0] = props.name;
47 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md
+1
@@ -78,6 +78,7 @@ function Component(t0) {
78 setState(5);
79 }
80 };
81 +
82 t3 = [state];
83 $[1] = state;
84 $[2] = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-in-statement.expect.md
+1
@@ -33,6 +33,7 @@ function Component(props) {
33 for (const key in props) {
34 items.push(<div key={key}>{key}</div>);
35 }
36 +
37 t0 = <div>{items}</div>;
38 $[0] = props;
39 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-loop-with-value-block-initializer.expect.md
+1
@@ -73,6 +73,7 @@ function Component(props) {
73 const item = props.items[i];
74 items.push(<div key={item.id}>{item.value}</div>);
75 }
76 +
77 t0 = <div>{items}</div>;
78 $[0] = props.items;
79 $[1] = props.start;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-mutate.expect.md
+1
@@ -38,6 +38,7 @@ function Component(_props) {
38 <div key={toJSON(item)}>{toJSON(mutateAndReturn(item))}</div>,
39 );
40 }
41 +
42 t0 = <div>{results}</div>;
43 $[0] = t0;
44 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/function-expression-maybe-mutates-hook-return-value.expect.md
+1
@@ -29,6 +29,7 @@ function Component(props) {
29 const onLoad = () => {
30 log(id);
31 };
32 +
33 t0 = <Foo onLoad={onLoad} />;
34 $[0] = id;
35 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/function-expression-prototype-call.expect.md
+1
@@ -27,6 +27,7 @@ function Component(props) {
27 const f = function () {
28 return <div>{props.name}</div>;
29 };
30 +
31 t0 = f.call();
32 $[0] = props;
33 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-jsx-tag-lowered-between-mutations.expect.md
+1
@@ -29,6 +29,7 @@ function Component(props) {
29 let t0;
30 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31 const maybeMutable = new MaybeMutable();
32 +
33 t0 = <View>{maybeMutate(maybeMutable)}</View>;
34 $[0] = t0;
35 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-types/set-constructor-arg.expect.md
+1
@@ -60,6 +60,7 @@ function useFoo(t0) {
60 if ($[3] !== propArr[1] || $[4] !== propArr[2]) {
61 s2 = new Set(MODULE_LOCAL.values());
62 s2.add(propArr[1]);
63 +
64 s3 = new Set(s2.values());
65 s3.add(propArr[2]);
66 $[3] = propArr[1];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/global-types/set-copy-constructor-mutate.expect.md
+1
@@ -41,6 +41,7 @@ function useFoo(t0) {
41 if ($[0] !== propArr[0]) {
42 s1 = new Set([1, 2, 3]);
43 s1.add(makeArray(propArr[0]));
44 +
45 s2 = new Set(s1);
46
47 mutate(s2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoist-destruct.expect.md
+1
@@ -37,6 +37,7 @@ function Foo() {
37 </div>
38 );
39 };
40 +
41 const [t1, t2] = [1, { x: 2 }];
42 const a = t1;
43 const { x: t3, y: t4 } = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-computed-member-expression.expect.md
+3
@@ -39,11 +39,14 @@ function hoisting() {
39 const onClick = function onClick() {
40 return bar.baz;
41 };
42 +
43 const onClick2 = function onClick2() {
44 return bar[baz];
45 };
46 +
47 const baz = "baz";
48 const bar = { baz: 1 };
49 +
50 t0 = (
51 <Stringify onClick={onClick} onClick2={onClick2} shouldInvokeFns={true} />
52 );
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.expect.md
+1
@@ -66,6 +66,7 @@ function Component(t0) {
66 return null;
67 }
68 };
69 +
70 t1 = <Stringify shouldInvokeFns={true} callback={callback} />;
71 $[0] = isObjNull;
72 $[1] = obj;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-let-declaration-without-initialization.expect.md
+2
@@ -36,10 +36,12 @@ function useHook(t0) {
36 let t1;
37 if ($[0] !== cond) {
38 const getX = () => x;
39 +
40 let x;
41 if (cond) {
42 x = CONST_NUMBER1;
43 }
44 +
45 t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
46 $[0] = cond;
47 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-member-expression.expect.md
+2
@@ -34,7 +34,9 @@ function hoisting() {
34 const onClick = function onClick(x) {
35 return x + bar.baz;
36 };
37 +
38 const bar = { baz: 1 };
39 +
40 t0 = <Stringify onClick={onClick} />;
41 $[0] = t0;
42 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-nested-const-declaration.expect.md
+3
@@ -36,10 +36,13 @@ function hoisting() {
36 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37 const qux = () => {
38 let result;
39 +
40 result = foo();
41 return result;
42 };
43 +
44 const foo = () => bar + baz;
45 +
46 const bar = 3;
47 const baz = 2;
48 t0 = qux();
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-nested-let-declaration.expect.md
+3
@@ -36,10 +36,13 @@ function hoisting() {
36 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37 const qux = () => {
38 let result;
39 +
40 result = foo();
41 return result;
42 };
43 +
44 let foo = () => bar + baz;
45 +
46 let bar = 3;
47 const baz = 2;
48 t0 = qux();
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-object-method.expect.md
+1
@@ -36,6 +36,7 @@ function hoisting() {
36 },
37 };
38 const bar = _temp;
39 +
40 t0 = x.foo();
41 $[0] = t0;
42 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-reassigned-let-declaration.expect.md
+2
@@ -36,11 +36,13 @@ function useHook(t0) {
36 let t1;
37 if ($[0] !== cond) {
38 const getX = () => x;
39 +
40 let x = CONST_NUMBER0;
41 if (cond) {
42 x = x + CONST_NUMBER1;
43 x;
44 }
45 +
46 t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
47 $[0] = cond;
48 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-reassigned-twice-let-declaration.expect.md
+2
@@ -37,12 +37,14 @@ function useHook(t0) {
37 let t1;
38 if ($[0] !== cond) {
39 const getX = () => x;
40 +
41 let x = CONST_NUMBER0;
42 if (cond) {
43 x = x + CONST_NUMBER1;
44 x;
45 x = Math.min(x, 100);
46 }
47 +
48 t1 = <Stringify getX={getX} shouldInvokeFns={true} />;
49 $[0] = cond;
50 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-recursive-call.expect.md
+1
@@ -37,6 +37,7 @@ function Foo(t0) {
37 return x * factorial(x - 1);
38 }
39 };
40 +
41 t1 = factorial(value);
42 $[0] = value;
43 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-repro-variable-used-in-assignment.expect.md
+1
@@ -30,6 +30,7 @@ function get2() {
30 const copy = x;
31 return copy;
32 };
33 +
34 const x = 2;
35 t0 = callbk();
36 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-setstate-captured-indirectly-jsx.expect.md
+1
@@ -49,6 +49,7 @@ function useFoo() {
49 let t2;
50 if ($[2] !== handleLogout) {
51 const getComponent = () => <ColumnItem onPress={() => handleLogout()} />;
52 +
53 t2 = getComponent();
54 $[2] = handleLogout;
55 $[3] = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-simple-function-expression.expect.md
+2
@@ -30,7 +30,9 @@ function hoisting() {
30 let t0;
31 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32 const foo = () => bar();
33 +
34 const bar = _temp;
35 +
36 t0 = foo();
37 $[0] = t0;
38 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md
+1
@@ -61,6 +61,7 @@ function Component() {
61 let t1;
62 if ($[2] !== state) {
63 const doubledArray = makeArray(state);
64 +
65 t1 = doubledArray.join("");
66 $[2] = state;
67 $[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/idx-no-outlining.expect.md
+1
@@ -29,6 +29,7 @@ function Component(props) {
29 let t0;
30 if ($[0] !== props) {
31 var _ref;
32 +
33 t0 =
34 (_ref = props) != null
35 ? (_ref = _ref.group) != null
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md
+1
@@ -30,6 +30,7 @@ function Component(props) {
30 let items;
31 if ($[0] !== props.a || $[1] !== props.cond) {
32 let t0;
33 +
34 if (props.cond) {
35 t0 = [];
36 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/incompatible-destructuring-kinds.expect.md
+1
@@ -34,6 +34,7 @@ function Component(t0) {
34 let t1;
35 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36 a = "a";
37 +
38 const [t2, t3] = [null, null];
39 t1 = t3;
40 a = t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-nested-object-method.expect.md
+1
@@ -40,6 +40,7 @@ function Test() {
40 return _temp;
41 },
42 };
43 +
44 t0 = <Stringify value={context} shouldInvokeFns={true} />;
45 $[0] = t0;
46 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked/conditional-call-chain.expect.md
+1
@@ -77,6 +77,7 @@ function Component(t0) {
77 hasLogged.current = true;
78 }
79 };
80 +
81 t3 = <Stringify log={log} shouldInvokeFns={true} />;
82 $[4] = logA;
83 $[5] = logB;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked/use-memo-returned.expect.md
+1
@@ -48,6 +48,7 @@ import { useIdentity } from "shared-runtime";
48 function useMakeCallback(t0) {
49 const $ = _c(2);
50 const { obj, shouldSynchronizeState } = t0;
51 +
52 const [, setState] = useState(0);
53 let t1;
54 if ($[0] !== obj.value) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
+1
@@ -33,6 +33,7 @@ function Component(props) {
33 let t1;
34 if ($[0] !== item) {
35 const count = new MaybeMutable(item);
36 +
37 T1 = View;
38 T0 = View;
39 if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md
+1
@@ -25,6 +25,7 @@ function Component(props) {
25 let t0;
26 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
27 const count = new MaybeMutable();
28 +
29 t0 = (
30 <View>
31 <View>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/invalid-setState-in-useEffect-transitive.expect.md
+1
@@ -35,6 +35,7 @@ function Component() {
35 const f = () => {
36 setState(_temp);
37 };
38 +
39 t0 = () => {
40 f();
41 };
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md
+1
@@ -59,6 +59,7 @@ function Component(props) {
59 if ($[0] !== props.alternateComponent || $[1] !== props.component) {
60 const maybeMutable = new MaybeMutable();
61 Tag = props.component;
62 +
63 T0 = Tag;
64 t0 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
65 $[0] = props.alternateComponent;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-array-access-member-expr-captured.expect.md
+2
@@ -32,7 +32,9 @@ function Foo() {
32 let t0;
33 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34 const x = [{ value: 0 }, { value: 1 }, { value: 2 }];
35 +
36 const foo = () => x[CONST_NUMBER0].value;
37 +
38 t0 = invoke(foo);
39 $[0] = t0;
40 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-array-access-member-expr-param.expect.md
+1
@@ -32,6 +32,7 @@ function Foo() {
32 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
33 const x = [{ value: 0 }, { value: 1 }, { value: 2 }];
34 const foo = (param) => x[param].value;
35 +
36 t0 = invoke(foo, 1);
37 $[0] = t0;
38 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md
+2
@@ -46,10 +46,12 @@ function CaptureNotMutate(props) {
46 let aliasedElement;
47 if ($[2] !== idx || $[3] !== props.el) {
48 const element = bar(props.el);
49 +
50 const fn = function () {
51 const arr = { element };
52 return arr[idx];
53 };
54 +
55 aliasedElement = fn();
56 mutate(aliasedElement);
57 $[2] = idx;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/maybe-mutate-object-in-callback.expect.md
+1
@@ -36,6 +36,7 @@ function Component(props) {
36 let t0;
37 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
38 const object = {};
39 +
40 t0 = () => {
41 mutate(object);
42 };
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/multiple-calls-to-hoisted-callback-from-other-callback.expect.md
+3
@@ -43,15 +43,18 @@ function Component(props) {
43 let t0;
44 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
45 const a = () => b();
46 +
47 const b = () => (
48 <>
49 <div onClick={() => onClick(true)}>a</div>
50 <div onClick={() => onClick(false)}>b</div>
51 </>
52 );
53 +
54 const onClick = (value) => {
55 setState(value);
56 };
57 +
58 t0 = <div>{a()}</div>;
59 $[0] = t0;
60 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md
+5
@@ -94,14 +94,19 @@ function testFunction(props) {
94 break;
95 }
96 }
97 +
98 if (a) {
99 }
100 +
101 if (b) {
102 }
103 +
104 if (c) {
105 }
106 +
107 if (d) {
108 }
109 +
110 mutate(d, null);
111 t0 = { a, b, c, d };
112 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md
+1
@@ -74,6 +74,7 @@ function Component(props) {
74 const b = [a];
75 const c = {};
76 const d = { c };
77 +
78 x = {};
79 x.b = b;
80 const y = mutate(x, d);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutate-outer-scope-within-value-block.expect.md
+1
@@ -76,6 +76,7 @@ function useFoo(t0) {
76 let t1;
77 if ($[0] !== input) {
78 const arr = shallowCopy(input);
79 +
80 const cond = identity(false);
81 t1 = cond ? { val: CONST_TRUE } : mutate(arr);
82 $[0] = input;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutation-during-jsx-construction.expect.md
+1
@@ -32,6 +32,7 @@ function Component(props) {
32 let element;
33 if ($[0] !== props.value) {
34 const key = {};
35 +
36 element = <div key={mutateAndReturnNewValue(key)}>{props.value}</div>;
37
38 mutate(key);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutation-within-capture-and-mutablerange.expect.md
+1
@@ -58,6 +58,7 @@ function useFoo(t0) {
58 const x = { a };
59 const y = [b];
60 mutate(x);
61 +
62 z = [mutate(y)];
63
64 mutate(y);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/aliased-nested-scope-truncated-dep.expect.md
+3
@@ -182,9 +182,12 @@ function Component(t0) {
182 if ($[0] !== prop) {
183 const obj = shallowCopy(prop);
184 const aliasedObj = identity(obj);
185 +
186 const id = [obj.id];
187 +
188 mutate(aliasedObj);
189 setPropertyByKey(aliasedObj, "id", prop.id + 1);
190 +
191 t1 = <Stringify id={id} />;
192 $[0] = prop;
193 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/basic-mutation-via-function-expression.expect.md
+1
@@ -31,6 +31,7 @@ function Component(t0) {
31 y.x = x;
32 mutate(y);
33 };
34 +
35 f();
36 t1 = <div>{x}</div>;
37 $[0] = a;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/capture-backedge-phi-with-later-mutation.expect.md
+1
@@ -53,6 +53,7 @@ function Component(t0) {
53 let z;
54 if ($[0] !== prop1 || $[1] !== prop2) {
55 let x = [{ value: prop1 }];
56 +
57 while (x.length < 2) {
58 arrayPush(x, { value: prop2 });
59
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/capture-in-function-expression-indirect.expect.md
+1
@@ -48,6 +48,7 @@ function Component(t0) {
48 const b = { x };
49 a.y.x = b;
50 };
51 +
52 f0();
53 mutate(y);
54 t1 = <Stringify x={y} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/iife-return-modified-later-phi.expect.md
+1
@@ -30,6 +30,7 @@ function Component(props) {
30 let items;
31 if ($[0] !== props.a || $[1] !== props.cond) {
32 let t0;
33 +
34 if (props.cond) {
35 t0 = [];
36 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-through-boxing-unboxing-function-call-indirections-2.expect.md
+1
@@ -41,6 +41,7 @@ function Component(t0) {
41 const y = [x];
42 return y[0];
43 };
44 +
45 const x0 = f();
46 const z = [x0];
47 const x1 = z[0];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-through-boxing-unboxing-function-call-indirections.expect.md
+1
@@ -42,6 +42,7 @@ function Component(t0) {
42 const x0 = y[0];
43 return [x0];
44 };
45 +
46 const z = f();
47 const x1 = z[0];
48 x1.key = "value";
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/object-expression-computed-member.expect.md
+1
@@ -32,6 +32,7 @@ function Component(props) {
32 let context;
33 if ($[0] !== props.value) {
34 const key = { a: "key" };
35 +
36 const t0 = key.a;
37 const t1 = identity([props.value]);
38 let t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-function-expression-effects-stack-overflow.expect.md
+1
@@ -45,6 +45,7 @@ function Component() {
45 .build({})
46 .build({});
47 };
48 +
49 t1 = <Stringify x={x} fn={fn} />;
50 $[1] = t1;
51 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-invalid-function-expression-effects-phi.expect.md
+2
@@ -38,8 +38,10 @@ function Component(t0) {
38 while (z == null) {
39 z = x;
40 }
41 +
42 z.y = y;
43 };
44 +
45 f();
46 mutate(x);
47 t1 = <div>{x}</div>;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/repro-jsx-captures-value-mutated-later.expect.md
+3
@@ -33,8 +33,11 @@ function Example() {
33 let t0;
34 if ($[0] !== data) {
35 const { a, b } = identity(data);
36 +
37 const el = <Stringify tooltip={b} />;
38 +
39 identity(a.at(0));
40 +
41 t0 = <Stringify icon={el} />;
42 $[0] = data;
43 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/useCallback-reordering-deplist-controlflow.expect.md
+2
@@ -56,7 +56,9 @@ function Foo(t0) {
56 let t2;
57 if ($[2] !== arr2 || $[3] !== foo || $[4] !== x) {
58 let y = [];
59 +
60 getVal1 = _temp;
61 +
62 t2 = () => [y];
63 foo ? (y = x.concat(arr2)) : y;
64 $[2] = arr2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/object-expression-computed-key-mutate-key-while-constructing-object.expect.md
+1
@@ -30,6 +30,7 @@ function Component(props) {
30 let t0;
31 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32 const key = {};
33 +
34 t0 = mutateAndReturn(key);
35 $[0] = t0;
36 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/object-expression-computed-member.expect.md
+1
@@ -31,6 +31,7 @@ function Component(props) {
31 let context;
32 if ($[0] !== props.value) {
33 const key = { a: "key" };
34 +
35 const t0 = key.a;
36 const t1 = identity([props.value]);
37 let t2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md
+1
@@ -27,6 +27,7 @@ function Component(props) {
27 let t0;
28 if ($[0] !== props) {
29 const x = makeOptionalFunction(props);
30 +
31 t0 = x?.(
32 <div>
33 <span>{props.text}</span>
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/capture-ref-for-later-mutation.expect.md
+1
@@ -46,6 +46,7 @@ function useKeyCommand() {
46 const nextPosition = direction === "left" ? addOne(position) : position;
47 currentPosition.current = nextPosition;
48 };
49 +
50 const moveLeft = { handler: handleKey("left") };
51 const moveRight = { handler: handleKey("right") };
52 t0 = [moveLeft, moveRight];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-array-push-consecutive-phis.expect.md
+2
@@ -75,7 +75,9 @@ function Component(props) {
75 } else {
76 y = [];
77 }
78 +
79 y.push(x);
80 +
81 t1 = [x, y];
82 $[1] = props.cond;
83 $[2] = props.cond2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-array-push.expect.md
+2
@@ -53,7 +53,9 @@ function Component(props) {
53 } else {
54 y = [];
55 }
56 +
57 y.push(x);
58 +
59 t1 = [x, y];
60 $[1] = props.cond;
61 $[2] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/phi-type-inference-property-store.expect.md
+2
@@ -49,7 +49,9 @@ function Component(props) {
49 } else {
50 y = { a: props.a };
51 }
52 +
53 y.x = x;
54 +
55 t1 = [x, y];
56 $[1] = props.a;
57 $[2] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/prune-nonescaping-useMemo-mult-returns-primitive.expect.md
+1
@@ -34,6 +34,7 @@ import { identity } from "shared-runtime";
34
35 function useFoo(cond) {
36 let t0;
37 +
38 if (cond) {
39 t0 = 2;
40 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/prune-nonescaping-useMemo-mult-returns.expect.md
+1
@@ -34,6 +34,7 @@ import { identity } from "shared-runtime";
34
35 function useFoo(cond) {
36 let t0;
37 +
38 if (cond) {
39 t0 = identity(10);
40 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-in-other-reactive-block.expect.md
+1
@@ -52,6 +52,7 @@ function useFoo(minWidth, otherProp) {
52 t1 = $[6];
53 }
54 const style = t1;
55 +
56 arrayPush(x, otherProp);
57 t0 = [style, x];
58 $[0] = minWidth;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-reordering-deplist-controlflow.expect.md
+2
@@ -56,7 +56,9 @@ function Foo(t0) {
56 let t2;
57 if ($[2] !== arr2 || $[3] !== foo || $[4] !== x) {
58 let y = [];
59 +
60 getVal1 = _temp;
61 +
62 t2 = () => [y];
63 foo ? (y = x.concat(arr2)) : y;
64 $[2] = arr2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-in-other-reactive-block.expect.md
+2
@@ -42,6 +42,7 @@ function useFoo(minWidth, otherProp) {
42 let t0;
43 if ($[0] !== minWidth || $[1] !== otherProp || $[2] !== width) {
44 const x = [];
45 +
46 const t1 = Math.max(minWidth, width);
47 let t2;
48 if ($[4] !== t1) {
@@ -52,6 +53,7 @@ function useFoo(minWidth, otherProp) {
53 t2 = $[5];
54 }
55 const style = t2;
56 +
57 arrayPush(x, otherProp);
58 t0 = [style, x];
59 $[0] = minWidth;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-reordering-depslist-controlflow.expect.md
+1
@@ -47,6 +47,7 @@ function Foo(t0) {
47 let val1;
48 if ($[0] !== arr1 || $[1] !== arr2 || $[2] !== foo) {
49 const x = [arr1];
50 +
51 let y = [];
52 let t2;
53 if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.expect.md
+4
@@ -45,9 +45,11 @@ function ComponentA(props) {
45 if (b) {
46 a.push(props.p0);
47 }
48 +
49 if (props.p1) {
50 b.push(props.p2);
51 }
52 +
53 t0 = <Foo a={a} b={b} />;
54 $[0] = props.p0;
55 $[1] = props.p1;
@@ -68,9 +70,11 @@ function ComponentB(props) {
70 if (mayMutate(b)) {
71 a.push(props.p0);
72 }
73 +
74 if (props.p1) {
75 b.push(props.p2);
76 }
77 +
78 t0 = <Foo a={a} b={b} />;
79 $[0] = props.p0;
80 $[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/iife-return-modified-later-phi.expect.md
+1
@@ -31,6 +31,7 @@ function Component(props) {
31 let items;
32 if ($[0] !== props.a || $[1] !== props.cond) {
33 let t0;
34 +
35 if (props.cond) {
36 t0 = [];
37 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/infer-component-props-non-null.expect.md
+1
@@ -47,6 +47,7 @@ function Foo(props) {
47 }
48 arr.push(t1);
49 }
50 +
51 t0 = <Stringify arr={arr} />;
52 $[0] = props.cond;
53 $[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push-consecutive-phis.expect.md
+2
@@ -76,7 +76,9 @@ function Component(props) {
76 } else {
77 y = [];
78 }
79 +
80 y.push(x);
81 +
82 t1 = [x, y];
83 $[1] = props.cond;
84 $[2] = props.cond2;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-array-push.expect.md
+2
@@ -54,7 +54,9 @@ function Component(props) {
54 } else {
55 y = [];
56 }
57 +
58 y.push(x);
59 +
60 t1 = [x, y];
61 $[1] = props.cond;
62 $[2] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/phi-type-inference-property-store.expect.md
+2
@@ -49,7 +49,9 @@ function Component(props) {
49 } else {
50 y = { a: props.a };
51 }
52 +
53 y.x = x;
54 +
55 t1 = [x, y];
56 $[1] = props.a;
57 $[2] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reduce-reactive-deps/infer-nested-function-uncond-access.expect.md
+1
@@ -36,6 +36,7 @@ function useFoo(t0) {
36 let t1;
37 if ($[0] !== a.b.c) {
38 const fn = () => () => ({ value: a.b.c });
39 +
40 t1 = <Stringify fn={fn} shouldInvokeFns={true} />;
41 $[0] = a.b.c;
42 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/reduce-reactive-deps/join-uncond-scopes-cond-deps.expect.md
+1
@@ -71,6 +71,7 @@ function useJoinCondDepsInUncondScopes(props) {
71 if (CONST_TRUE) {
72 setProperty(x, props.a.b);
73 }
74 +
75 setProperty(y, props.a.b);
76 t0 = [x, y];
77 $[0] = props.a.b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/ssa-leave-case.expect.md
+1
@@ -49,6 +49,7 @@ function Component(props) {
49 x.push(props.p1);
50 y = x;
51 }
52 +
53 t0 = (
54 <Stringify>
55 {x}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/switch.expect.md
+1
@@ -34,6 +34,7 @@ function Component(props) {
34 let y;
35 if ($[0] !== props.p0 || $[1] !== props.p2 || $[2] !== props.p3) {
36 const x = [];
37 +
38 switch (props.p0) {
39 case true: {
40 x.push(props.p2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/prune-scopes-whose-deps-invalidate-jsx.expect.md
+1
@@ -45,6 +45,7 @@ function Component(props) {
45 let t1;
46 if ($[2] !== x) {
47 const y = <div>{x}</div>;
48 +
49 t1 = <div>{y}</div>;
50 $[2] = x;
51 $[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/prune-scopes-whose-deps-may-invalidate-array.expect.md
+1
@@ -42,6 +42,7 @@ function Component(props) {
42 let t0;
43 if ($[0] !== x) {
44 const y = [x];
45 +
46 t0 = [y];
47 $[0] = x;
48 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-dependency-object-captured-with-reactive-mutated.expect.md
+1
@@ -34,6 +34,7 @@ function Component(props) {
34 const y = props.y;
35 const z = [x, y];
36 mutate(z);
37 +
38 t0 = [x];
39 $[0] = props.y;
40 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-scopes.expect.md
+1
@@ -35,6 +35,7 @@ function f(a, b) {
35 x.push(b);
36 }
37 }
38 +
39 t0 = <div>{x}</div>;
40 $[0] = a.length;
41 $[1] = b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md
+2
@@ -42,7 +42,9 @@ function Component(props) {
42 const b = [];
43 b.push(props.b);
44 a.a = null;
45 +
46 const c = [a];
47 +
48 t0 = [c, a];
49 $[0] = props.b;
50 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassign-in-while-loop-condition.expect.md
+1
@@ -39,6 +39,7 @@ function Component() {
39 while ((item = items.pop())) {
40 sum = sum + item;
41 }
42 +
43 t0 = [items, sum];
44 $[0] = t0;
45 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md
+3
@@ -29,6 +29,7 @@ function Component(props) {
29 let x = [];
30 x.push(props.p0);
31 const y = x;
32 +
33 if (props.p1) {
34 let t1;
35 if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
@@ -39,7 +40,9 @@ function Component(props) {
40 }
41 x = t1;
42 }
43 +
44 y.push(props.p2);
45 +
46 t0 = <Component x={x} y={y} />;
47 $[0] = props.p0;
48 $[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md
+1
@@ -49,6 +49,7 @@ function foo(a, b, c) {
49 if (a) {
50 x.push(a);
51 }
52 +
53 t0 = <div>{x}</div>;
54 $[0] = a;
55 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reassignment.expect.md
+2
@@ -36,7 +36,9 @@ function Component(props) {
36 t1 = $[3];
37 }
38 x = t1;
39 +
40 y.push(props.p1);
41 +
42 t0 = <Component x={x} y={y} />;
43 $[0] = props.p0;
44 $[1] = props.p1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/recursive-function-expression.expect.md
+1
@@ -62,6 +62,7 @@ function Component() {
62 }
63 return callback(x - 1);
64 }
65 +
66 t0 = callback(10);
67 $[0] = t0;
68 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/join-uncond-scopes-cond-deps.expect.md
+1
@@ -69,6 +69,7 @@ function useJoinCondDepsInUncondScopes(props) {
69 if (CONST_TRUE) {
70 setProperty(x, props.a.b);
71 }
72 +
73 setProperty(y, props.a.b);
74 t0 = [x, y];
75 $[0] = props.a.b;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-aliased-no-added-to-dep.expect.md
+1
@@ -28,6 +28,7 @@ function VideoTab() {
28 const x = () => {
29 console.log(t);
30 };
31 +
32 t0 = <VideoList videos={x} />;
33 $[0] = t0;
34 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-aliased-not-added-to-dep-2.expect.md
+1
@@ -25,6 +25,7 @@ function Foo(t0) {
25 let t1;
26 if ($[0] !== a) {
27 const x = { a, val };
28 +
29 t1 = <VideoList videos={x} />;
30 $[0] = a;
31 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-field-not-added-to-dep.expect.md
+1
@@ -26,6 +26,7 @@ function VideoTab() {
26 const x = () => {
27 console.log(ref.current.x);
28 };
29 +
30 t0 = <VideoList videos={x} />;
31 $[0] = t0;
32 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-field-write-not-added-to-dep.expect.md
+1
@@ -41,6 +41,7 @@ function Component() {
41 const inputChanged = (e) => {
42 ref.current.text.value = e.target.value;
43 };
44 +
45 t1 = <input onChange={inputChanged} />;
46 $[1] = t1;
47 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep-2.expect.md
+1
@@ -23,6 +23,7 @@ function Foo(t0) {
23 let t1;
24 if ($[0] !== a) {
25 const x = { a, val: ref.current };
26 +
27 t1 = <VideoList videos={x} />;
28 $[0] = a;
29 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep.expect.md
+1
@@ -25,6 +25,7 @@ function VideoTab() {
25 const x = () => {
26 console.log(ref.current);
27 };
28 +
29 t0 = <VideoList videos={x} />;
30 $[0] = t0;
31 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-optional-field-no-added-to-dep.expect.md
+1
@@ -25,6 +25,7 @@ function VideoTab() {
25 const x = () => {
26 ref.current?.x;
27 };
28 +
29 t0 = <VideoList videos={x} />;
30 $[0] = t0;
31 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ref-current-write-not-added-to-dep.expect.md
+1
@@ -25,6 +25,7 @@ function VideoTab() {
25 const x = () => {
26 ref.current = 1;
27 };
28 +
29 t0 = <VideoList videos={x} />;
30 $[0] = t0;
31 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/regexp-literal.expect.md
+1
@@ -26,6 +26,7 @@ function Component(props) {
26 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
27 const pattern = /foo/g;
28 value = makeValue();
29 +
30 t0 = pattern.test(value);
31 $[0] = t0;
32 $[1] = value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rename-source-variables-nested-function.expect.md
+1
@@ -57,6 +57,7 @@ function useFoo(props) {
57 };
58 return b;
59 };
60 +
61 t1 = a()()();
62 $0[0] = props.value;
63 $0[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-aliased-capture-aliased-mutate.expect.md
+1
@@ -73,6 +73,7 @@ function useFoo(t0) {
73 if ($[0] !== a || $[1] !== b) {
74 const x = [];
75 const y = { value: a };
76 +
77 arrayPush(x, y);
78 const y_alias = y;
79 const cb = () => y_alias.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-aliased-capture-mutate.expect.md
+2
@@ -54,12 +54,14 @@ function useFoo(t0) {
54 if ($[0] !== a) {
55 const arr = [];
56 const obj = { value: a };
57 +
58 setPropertyByKey(obj, "arr", arr);
59 const obj_alias = obj;
60 const cb = () => obj_alias.arr.length;
61 for (let i = 0; i < a; i++) {
62 arr.push(i);
63 }
64 +
65 t1 = <Stringify cb={cb} shouldInvokeFns={true} />;
66 $[0] = a;
67 $[1] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-false-positive-ref-validation-in-use-effect.expect.md
+1
@@ -68,6 +68,7 @@ function Component() {
68 update();
69 }
70 };
71 +
72 t2 = [update];
73 $[2] = update;
74 $[3] = t1;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-independently-memoized-property-load-for-method-call.expect.md
+3
@@ -61,8 +61,11 @@ function Component(t0) {
61 let timestampLabel;
62 if ($[0] !== highlightedItem || $[1] !== label || $[2] !== serverTime) {
63 const highlight = new Highlight(highlightedItem);
64 +
65 const time = serverTime.get();
66 +
67 timestampLabel = time / 1000 || label;
68 +
69 t1 = highlight.render();
70 $[0] = highlightedItem;
71 $[1] = label;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-instruction-part-of-already-closed-scope.expect.md
+1
@@ -46,6 +46,7 @@ function Component(t0) {
46 const a = identity(data, index);
47 const b = identity(data, index);
48 const c = identity(data, index);
49 +
50 const t4 = identity(b);
51 if ($[6] !== t4) {
52 t2 = <Stringify value={t4} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-missing-dependency-if-within-while.expect.md
+1
@@ -51,6 +51,7 @@ export default function Component(props) {
51 i++;
52 }
53 }
54 +
55 t0 = <>{items}</>;
56 $[0] = b;
57 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-ref-in-function-passed-to-hook.expect.md
+1
@@ -89,6 +89,7 @@ function Example() {
89 observer.disconnect();
90 };
91 };
92 +
93 t3 = [];
94 $[2] = t2;
95 $[3] = t3;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-result-of-function-call-with-frozen-argument-in-function-expression.expect.md
+1
@@ -39,6 +39,7 @@ function Example(props) {
39 obj.property = props.value;
40 return obj;
41 };
42 +
43 t0 = f();
44 $[0] = object;
45 $[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-mutate-result-of-method-call-on-frozen-value-in-function-expression.expect.md
+1
@@ -39,6 +39,7 @@ function Example(props) {
39 obj.property = props.value;
40 return obj;
41 };
42 +
43 t0 = f();
44 $[0] = object;
45 $[1] = props.value;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-declarations-in-reactive-scope-with-early-return.expect.md
+1
@@ -62,6 +62,7 @@ function Component() {
62 t1 = t2;
63 break bb0;
64 }
65 +
66 t0 = filteredItems.map(_temp2);
67 }
68 $[0] = items;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-value-for-temporary-reactive-scope-with-early-return.expect.md
+1
@@ -50,6 +50,7 @@ function Component(props) {
50 t1 = null;
51 break bb0;
52 }
53 +
54 t0 = (
55 <div className="foo">
56 {fbt._(
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md
+1
@@ -57,6 +57,7 @@ function Component(props) {
57 t1 = null;
58 break bb0;
59 }
60 +
61 t0 = identity(propsString);
62 }
63 $[0] = props;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.expect.md
+1
@@ -63,6 +63,7 @@ function Foo(t0) {
63 obj.value = newValue;
64 obj.a = a;
65 };
66 +
67 const updater = updaterFactory();
68 updater(b);
69 t1 = <Stringify cb={obj} shouldInvokeFns={true} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.expect.md
+1
@@ -61,6 +61,7 @@ function Foo(t0) {
61 const fnFactory = () => () => {
62 myVar = _temp;
63 };
64 +
65 let myVar = _temp2;
66 useIdentity();
67
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md
+2
@@ -53,7 +53,9 @@ function Component(props) {
53 let t0;
54 if ($[0] !== buttons) {
55 const [, ...nonPrimaryButtons] = buttons;
56 +
57 const renderedNonPrimaryButtons = nonPrimaryButtons.map(_temp);
58 +
59 t0 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
60 $[0] = buttons;
61 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-unmerged-fbt-call-merge-overlapping-reactive-scopes.expect.md
+1
@@ -44,6 +44,7 @@ function Component(props) {
44 [fbt._plural(props.value.length, "number")],
45 { hk: "4mUen7" },
46 );
47 +
48 t0 = props.cond ? (
49 <Stringify
50 description={fbt._("Text here", null, { hk: "21YpZs" })}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md
+1
@@ -58,6 +58,7 @@ function foo(props) {
58 if ($[0] !== props.a) {
59 x = [];
60 x.push(props.a);
61 +
62 t0 = <div>{x}</div>;
63 $[0] = props.a;
64 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md
+1
@@ -50,6 +50,7 @@ function Component(statusName) {
50 const { status, text: t2 } = foo(statusName);
51 text = t2;
52 const { bg, color } = getStyles(status);
53 +
54 t1 = identity(bg);
55 t0 = identity(color);
56 $[0] = statusName;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md
+2
@@ -52,8 +52,10 @@ function Component(statusName) {
52 if ($[0] !== statusName) {
53 const { status, text: t1 } = foo(statusName);
54 text = t1;
55 +
56 const { color, font: t2 } = getStyles(status);
57 font = t2;
58 +
59 t0 = identity(color);
60 $[0] = statusName;
61 $[1] = font;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md
+1
@@ -33,6 +33,7 @@ function Component(props) {
33 foo(a, b);
34 if (foo()) {
35 }
36 +
37 foo(a, b);
38 t0 = <div a={a} b={b} />;
39 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md
+1
@@ -28,6 +28,7 @@ function Component(props) {
28 const a = [];
29 const b = {};
30 foo(a, b);
31 +
32 foo(a, b);
33 t0 = <div a={a} b={b} />;
34 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md
+1
@@ -48,6 +48,7 @@ function Component(props) {
48 x.push(props.p1);
49 y = x;
50 }
51 +
52 t0 = (
53 <Stringify>
54 {x}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md
+1
@@ -25,6 +25,7 @@ function foo() {
25 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
26 const a = {};
27 const x = a;
28 +
29 y = {};
30 y.x = x;
31
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/static-components/invalid-dynamically-constructed-component-function.expect.md
+1
@@ -23,6 +23,7 @@ function Example(props) {
23 const Component = function Component() {
24 return <div />;
25 };
26 +
27 t0 = <Component />;
28 $[0] = t0;
29 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/switch.expect.md
+1
@@ -33,6 +33,7 @@ function Component(props) {
33 let y;
34 if ($[0] !== props.p0 || $[1] !== props.p2 || $[2] !== props.p3) {
35 const x = [];
36 +
37 switch (props.p0) {
38 case true: {
39 x.push(props.p2);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-function-expression-captures-value-later-frozen.expect.md
+3
@@ -28,11 +28,14 @@ function Component(props) {
28 let t0;
29 if ($[0] !== props.cond) {
30 const x = {};
31 +
32 const onChange = (e) => {
33 maybeMutate(x, e.target.value);
34 };
35 +
36 if (props.cond) {
37 }
38 +
39 onChange();
40 t0 = <Foo value={x} />;
41 $[0] = props.cond;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-global-property-load-cached.expect.md
+1
@@ -45,6 +45,7 @@ function Component(t0) {
45 let t1;
46 if ($[0] !== num) {
47 const arr = makeArray(num);
48 +
49 T0 = SharedRuntime.Stringify;
50 t1 = arr.push(num);
51 $[0] = num;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transitive-freeze-array.expect.md
+1
@@ -36,6 +36,7 @@ function Component(props) {
36 const y = {};
37 const items = [x, y];
38 items.pop();
39 +
40 mutate(y);
41 t0 = [x, y, items];
42 $[0] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md
+1
@@ -59,6 +59,7 @@ function Component(props) {
59 if (isLoadingNext) {
60 return;
61 }
62 +
63 loadMoreWithTiming();
64 };
65 t2 = [isLoadingNext, loadMoreWithTiming];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-within-function-expression-returns-caught-value.expect.md
+1
@@ -40,6 +40,7 @@ function Component(props) {
40 return e;
41 }
42 };
43 +
44 t0 = callback();
45 $[0] = props;
46 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md
+1
@@ -29,6 +29,7 @@ function component() {
29 let x;
30 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31 const o = {};
32 +
33 x = {};
34
35 x.t = p;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useActionState-dispatch-considered-as-non-reactive.expect.md
+1
@@ -35,6 +35,7 @@ function Component() {
35 const onSubmitAction = () => {
36 dispatchAction();
37 };
38 +
39 t0 = <Foo onSubmitAction={onSubmitAction} />;
40 $[0] = t0;
41 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useContext-read-context-in-callback-if-condition.expect.md
+1
@@ -50,6 +50,7 @@ function Component(props) {
50 return null;
51 }
52 };
53 +
54 t0 = getValue();
55 $[0] = foo.current;
56 $[1] = t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useReducer-returned-dispatcher-is-non-reactive.expect.md
+1
@@ -36,6 +36,7 @@ function f() {
36 const onClick = () => {
37 dispatch();
38 };
39 +
40 t0 = <div onClick={onClick} />;
41 $[0] = t0;
42 } else {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/valid-setState-in-effect-from-ref-function-call.expect.md
+1
@@ -50,6 +50,7 @@ function Component() {
50 }
51 return 100;
52 };
53 +
54 setWidth(getBoundingRect(ref));
55 };
56 t1 = [];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/valid-setState-in-useEffect-controlled-by-ref-value.expect.md
+1
@@ -71,6 +71,7 @@ function Component(t0) {
71 setData(data_0);
72 }
73 };
74 +
75 t2 = [x, y];
76 $[0] = x;
77 $[1] = y;