@samitouri / QOS-React / commits / 329bb555a0

[RFC] Stabilize naming of promoted temporaries

When the compiler promotes temporary values to named variables, we currently eagerly assign a name using the temporary's IdentifierId. This means that we're sort of stuck with this name later in compilation, and RenameVariables can't be 100% sure whether a 't0' variable is a temporary or not. As a result, the names of these promoted temporaries is influenced by how many temporaries we happened to create during compilation (and what the next available identifier id was), making them fluctuate more as we iterate on the compiler. This is an RFC for showing how we can stabilize these names. The key elements: * Distinguish promoted temporaries from other named identifiers. Here we use a hack, naming them starting with '#t' or '#T', since '#' isn't a valid identifier starting point. This lets us keep all of our logic that looks for non-null identifiers names to distinguish named/unnamed, while also distinguishing real names from generated names (if this was Rust, we'd use an Enum and have a "isNamed()" method on it that was true for real/temporary names and false otherwise) * In RenameVariables, detect generated names and fall back to generating the next available `tN`-style name (or `TN` for JSX tags). * To reduce thrash overall, RenameVariables no longer keeps a global "next id" value that uses to distinguish all conflicting identifiers, instead we restart at 0 whenever we find a conflict, and keep bumping until we find a free name. Thus if both `foo` and `bar` had conflicts, we previously would end up with `foo$0` and `bar$1` as the deduped names, but now will end up with `foo$0` and `bar$0`. ## RFC I'm open to feedback on the approach. Two main questions: * How to annotate promoted temporaries. The most type-safe option is to change `Identifier.name` to be a union of `{kind: 'named', value: string} | `{kind: 'promoted', value: string} | `{kind: 'temporary'}` though TS then wouldn't allow `identifier.name.value` (even as nullable) since it doesn't exist on one of the variants. Maybe we could type the temporary one as `{kind: 'temporary', value?: null}` so the value has to be null but you can always access that property? * ?? Other concerns about the approach? We could keep the global auto-incrementing id rather than attempting to reset to 0 for each conflict.

Joe Savona committed Mar 6, 2024 at 11:07 UTC 329bb555a0bfd99d22eb8374835699c2278224f9
76 files changed +770 -737
compiler/packages/babel-plugin-react-forget/src/Inference/InlineImmediatelyInvokedFunctionExpressions.ts
+1 -1
@@ -295,5 +295,5 @@ function declareTemporary(
295 }
296
297 function promoteTemporary(temp: Identifier): void {
298 - temp.name = `t${temp.id}`;
298 + temp.name = `#t${temp.id}`;
299 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.ts
+1 -1
@@ -152,7 +152,7 @@ function transformDestructuring(
152 const tempId = state.env.nextIdentifierId;
153 const temporary = {
154 ...place,
155 - identifier: { ...place.identifier, id: tempId, name: `t${tempId}` },
155 + identifier: { ...place.identifier, id: tempId, name: `#t${tempId}` },
156 };
157 renamed.set(place, temporary);
158 return temporary;
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts
+2 -2
@@ -85,8 +85,8 @@ function promoteTemporary(identifier: Identifier, state: VisitorState): void {
85 suggestions: null,
86 });
87 if (state.tags.has(identifier.id)) {
88 - identifier.name = `T${state.nextId++}`;
88 + identifier.name = `#T${state.nextId++}`;
89 } else {
90 - identifier.name = `t${state.nextId++}`;
90 + identifier.name = `#t${state.nextId++}`;
91 }
92 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts
+1 -1
@@ -274,7 +274,7 @@ class Transform extends ReactiveFunctionTransform<State> {
274 earlyReturnValue = state.earlyReturnValue;
275 } else {
276 const identifier = createTemporaryPlace(this.env).identifier;
277 - identifier.name = `t${identifier.id}`;
277 + identifier.name = `#t${identifier.id}`;
278 earlyReturnValue = {
279 label: this.env.nextBlockId,
280 loc,
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/RenameVariables.ts
+60 -27
@@ -13,26 +13,38 @@ import {
13 Place,
14 ReactiveBlock,
15 ReactiveFunction,
16 - ReactiveInstruction,
16 ReactiveScopeBlock,
17 } from "../HIR/HIR";
19 -import { eachInstructionLValue } from "../HIR/visitors";
20 -import {
21 - ReactiveFunctionVisitor,
22 - eachReactiveValueOperand,
23 - visitReactiveFunction,
24 -} from "./visitors";
18 +import { ReactiveFunctionVisitor, visitReactiveFunction } from "./visitors";
19
26 -/*
20 +/**
21 * Ensures that each named variable in the given function has a unique name
22 * that does not conflict with any other variables in the same block scope.
23 * Note that the scoping is based on the final inferred blocks, not the
24 * block scopes that were present in the original source. Thus variables
25 * that shadowed in the original source may end up with unique names in the
26 * output, if Forget would merge those two blocks into a single scope.
27 + *
28 + * Variables are renamed using their original name followed by a number,
29 + * starting with 0 and incrementing until a unique name is found. Eg if the
30 + * compiler collapses three scopes that each had their own `foo` declaration,
31 + * they will be renamed to `foo`, `foo0`, and `foo1`, assuming that no conflicts'
32 + * exist for `foo0` and `foo1`.
33 + *
34 + * For temporary values that are promoted to named variables, the starting name
35 + * is "T0" for values that appear in JSX tag position and "t0" otherwise. If this
36 + * name conflicts, the number portion increments until the name is unique (t1, t2, etc).
37 */
38 export function renameVariables(fn: ReactiveFunction): void {
39 const scopes = new Scopes();
40 + renameVariablesImpl(fn, new Visitor(), scopes);
41 +}
42 +
43 +function renameVariablesImpl(
44 + fn: ReactiveFunction,
45 + visitor: Visitor,
46 + scopes: Scopes
47 +): void {
48 scopes.enter(() => {
49 for (const param of fn.params) {
50 if (param.kind === "Identifier") {
@@ -41,11 +53,14 @@ export function renameVariables(fn: ReactiveFunction): void {
53 scopes.visit(param.place.identifier);
54 }
55 }
44 - visitReactiveFunction(fn, new Visitor(), scopes);
56 + visitReactiveFunction(fn, visitor, scopes);
57 });
58 }
59
60 class Visitor extends ReactiveFunctionVisitor<Scopes> {
61 + override visitLValue(_id: InstructionId, lvalue: Place, state: Scopes): void {
62 + state.visit(lvalue.identifier);
63 + }
64 override visitPlace(id: InstructionId, place: Place, state: Scopes): void {
65 state.visit(place.identifier);
66 }
@@ -54,40 +69,58 @@ class Visitor extends ReactiveFunctionVisitor<Scopes> {
69 this.traverseBlock(block, state);
70 });
71 }
57 - override visitInstruction(instr: ReactiveInstruction, state: Scopes): void {
58 - for (const operand of eachReactiveValueOperand(instr.value)) {
59 - state.visit(operand.identifier);
60 - }
61 - for (const operand of eachInstructionLValue(instr)) {
62 - this.visitPlace(instr.id, operand, state);
72 +
73 + override visitScope(scope: ReactiveScopeBlock, state: Scopes): void {
74 + for (const [_, declaration] of scope.scope.declarations) {
75 + state.visit(declaration.identifier);
76 }
77 + this.traverseScope(scope, state);
78 }
65 - override visitScope(scope: ReactiveScopeBlock, state: Scopes): void {
66 - /*
67 - * Intentionally bypass visitBlock() since scopes do not introduce a new
68 - * block scope
69 - */
70 - this.traverseBlock(scope.instructions, state);
79 +
80 + override visitReactiveFunctionValue(
81 + _id: InstructionId,
82 + _dependencies: Place[],
83 + _fn: ReactiveFunction,
84 + _state: Scopes
85 + ): void {
86 + renameVariablesImpl(_fn, this, _state);
87 }
88 }
89
90 class Scopes {
75 - #nextId: number = 0;
76 - #seen: Set<IdentifierId> = new Set();
91 + #seen: Map<IdentifierId, string> = new Map();
92 #stack: Array<Map<string, IdentifierId>> = [new Map()];
93
94 visit(identifier: Identifier): void {
80 - if (identifier.name === null || this.#seen.has(identifier.id)) {
95 + const originalName = identifier.name;
96 + if (originalName === null) {
97 + return;
98 + }
99 + const mappedName = this.#seen.get(identifier.id);
100 + if (mappedName !== undefined) {
101 + identifier.name = mappedName;
102 return;
103 }
83 - this.#seen.add(identifier.id);
84 - let name = identifier.name;
104 + let name = originalName;
105 + let id = 0;
106 + if (name.startsWith("#t")) {
107 + name = `t${id++}`;
108 + } else if (name.startsWith("#T")) {
109 + name = `T${id++}`;
110 + }
111 let previous = this.#lookup(name);
112 while (previous !== null) {
87 - name = `${identifier.name}$${this.#nextId++}`;
113 + if (originalName.startsWith("#t")) {
114 + name = `t${id++}`;
115 + } else if (originalName.startsWith("#T")) {
116 + name = `T${id++}`;
117 + } else {
118 + name = `${identifier.name}$${id++}`;
119 + }
120 previous = this.#lookup(name);
121 }
122 identifier.name = name;
123 + this.#seen.set(identifier.id, name);
124 this.#stack.at(-1)!.set(name, identifier.id);
125 }
126
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md
+5 -5
@@ -49,16 +49,16 @@ function AllocatingPrimitiveAsDepNested(props) {
49 x = $[2];
50 y = $[3];
51 }
52 - let t2;
52 + let t0;
53 if ($[6] !== x || $[7] !== y) {
54 - t2 = [x, y];
54 + t0 = [x, y];
55 $[6] = x;
56 $[7] = y;
57 - $[8] = t2;
57 + $[8] = t0;
58 } else {
59 - t2 = $[8];
59 + t0 = $[8];
60 }
61 - return t2;
61 + return t0;
62 }
63
64 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md
+5 -5
@@ -50,16 +50,16 @@ function foo(a, b, c) {
50 x = $[3];
51 z = $[4];
52 }
53 - let t1;
53 + let t0;
54 if ($[7] !== x || $[8] !== z) {
55 - t1 = [x, z];
55 + t0 = [x, z];
56 $[7] = x;
57 $[8] = z;
58 - $[9] = t1;
58 + $[9] = t0;
59 } else {
60 - t1 = $[9];
60 + t0 = $[9];
61 }
62 - return t1;
62 + return t0;
63 }
64
65 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md
+9 -9
@@ -40,24 +40,24 @@ function ArrayAtTest(props) {
40 t1 = $[3];
41 }
42 const arr = t1;
43 - let t3;
43 + let t2;
44 if ($[4] !== props.y || $[5] !== arr) {
45 - let t2;
45 + let t3;
46 if ($[7] !== props.y) {
47 - t2 = bar(props.y);
47 + t3 = bar(props.y);
48 $[7] = props.y;
49 - $[8] = t2;
49 + $[8] = t3;
50 } else {
51 - t2 = $[8];
51 + t3 = $[8];
52 }
53 - t3 = arr.at(t2);
53 + t2 = arr.at(t3);
54 $[4] = props.y;
55 $[5] = arr;
56 - $[6] = t3;
56 + $[6] = t2;
57 } else {
58 - t3 = $[6];
58 + t2 = $[6];
59 }
60 - const result = t3;
60 + const result = t2;
61 return result;
62 }
63
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md
+22 -22
@@ -32,51 +32,51 @@ import {
32 function Component(props) {
33 const $ = useMemoCache(4);
34 const [x] = useState(0);
35 - let t15;
35 let t0;
36 + let t1;
37 if ($[0] !== x) {
38 - t0 = calculateExpensiveNumber(x);
38 + t1 = calculateExpensiveNumber(x);
39 $[0] = x;
40 - $[1] = t0;
40 + $[1] = t1;
41 } else {
42 - t0 = $[1];
42 + t1 = $[1];
43 }
44 - t15 = t0;
45 - const expensiveNumber = t15;
46 - let t1;
44 + t0 = t1;
45 + const expensiveNumber = t0;
46 + let t2;
47 if ($[2] !== expensiveNumber) {
48 - t1 = <div>{expensiveNumber}</div>;
48 + t2 = <div>{expensiveNumber}</div>;
49 $[2] = expensiveNumber;
50 - $[3] = t1;
50 + $[3] = t2;
51 } else {
52 - t1 = $[3];
52 + t2 = $[3];
53 }
54 - return t1;
54 + return t2;
55 }
56
57 function Component2(props) {
58 const $ = useMemoCache(4);
59 const [x] = useState(0);
60 - let t15;
60 let t0;
61 + let t1;
62 if ($[0] !== x) {
63 - t0 = calculateExpensiveNumber(x);
63 + t1 = calculateExpensiveNumber(x);
64 $[0] = x;
65 - $[1] = t0;
65 + $[1] = t1;
66 } else {
67 - t0 = $[1];
67 + t1 = $[1];
68 }
69 - t15 = t0;
70 - const expensiveNumber = t15;
71 - let t1;
69 + t0 = t1;
70 + const expensiveNumber = t0;
71 + let t2;
72 if ($[2] !== expensiveNumber) {
73 - t1 = <div>{expensiveNumber}</div>;
73 + t2 = <div>{expensiveNumber}</div>;
74 $[2] = expensiveNumber;
75 - $[3] = t1;
75 + $[3] = t2;
76 } else {
77 - t1 = $[3];
77 + t2 = $[3];
78 }
79 - return t1;
79 + return t2;
80 }
81
82 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md
+22 -22
@@ -34,51 +34,51 @@ import {
34 function Component(props) {
35 const $ = useMemoCache(4);
36 const [x] = useState(0);
37 - let t15;
37 let t0;
38 + let t1;
39 if ($[0] !== x) {
40 - t0 = calculateExpensiveNumber(x);
40 + t1 = calculateExpensiveNumber(x);
41 $[0] = x;
42 - $[1] = t0;
42 + $[1] = t1;
43 } else {
44 - t0 = $[1];
44 + t1 = $[1];
45 }
46 - t15 = t0;
47 - const expensiveNumber = t15;
48 - let t1;
46 + t0 = t1;
47 + const expensiveNumber = t0;
48 + let t2;
49 if ($[2] !== expensiveNumber) {
50 - t1 = <div>{expensiveNumber}</div>;
50 + t2 = <div>{expensiveNumber}</div>;
51 $[2] = expensiveNumber;
52 - $[3] = t1;
52 + $[3] = t2;
53 } else {
54 - t1 = $[3];
54 + t2 = $[3];
55 }
56 - return t1;
56 + return t2;
57 }
58
59 function Component2(props) {
60 const $ = useMemoCache(4);
61 const [x] = useState(0);
62 - let t15;
62 let t0;
63 + let t1;
64 if ($[0] !== x) {
65 - t0 = calculateExpensiveNumber(x);
65 + t1 = calculateExpensiveNumber(x);
66 $[0] = x;
67 - $[1] = t0;
67 + $[1] = t1;
68 } else {
69 - t0 = $[1];
69 + t1 = $[1];
70 }
71 - t15 = t0;
72 - const expensiveNumber = t15;
73 - let t1;
71 + t0 = t1;
72 + const expensiveNumber = t0;
73 + let t2;
74 if ($[2] !== expensiveNumber) {
75 - t1 = <div>{expensiveNumber}</div>;
75 + t2 = <div>{expensiveNumber}</div>;
76 $[2] = expensiveNumber;
77 - $[3] = t1;
77 + $[3] = t2;
78 } else {
79 - t1 = $[3];
79 + t2 = $[3];
80 }
81 - return t1;
81 + return t2;
82 }
83
84 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md
+11 -11
@@ -29,26 +29,26 @@ import { calculateExpensiveNumber } from "shared-runtime";
29 function Component(props) {
30 const $ = useMemoCache(4);
31 const [x] = React.useState(0);
32 - let t17;
32 let t0;
33 + let t1;
34 if ($[0] !== x) {
35 - t0 = calculateExpensiveNumber(x);
35 + t1 = calculateExpensiveNumber(x);
36 $[0] = x;
37 - $[1] = t0;
37 + $[1] = t1;
38 } else {
39 - t0 = $[1];
39 + t1 = $[1];
40 }
41 - t17 = t0;
42 - const expensiveNumber = t17;
43 - let t1;
41 + t0 = t1;
42 + const expensiveNumber = t0;
43 + let t2;
44 if ($[2] !== expensiveNumber) {
45 - t1 = <div>{expensiveNumber}</div>;
45 + t2 = <div>{expensiveNumber}</div>;
46 $[2] = expensiveNumber;
47 - $[3] = t1;
47 + $[3] = t2;
48 } else {
49 - t1 = $[3];
49 + t2 = $[3];
50 }
51 - return t1;
51 + return t2;
52 }
53
54 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/block-scoping-switch-variable-scoping.expect.md
+7 -7
@@ -34,16 +34,16 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
34
35 function Component(props) {
36 const $ = useMemoCache(2);
37 - let t22;
37 let t0;
38 + let t1;
39 if ($[0] !== props.value) {
40 - t0 = { value: props.value };
40 + t1 = { value: props.value };
41 $[0] = props.value;
42 - $[1] = t0;
42 + $[1] = t1;
43 } else {
44 - t0 = $[1];
44 + t1 = $[1];
45 }
46 - const handlers = t0;
46 + const handlers = t1;
47 bb2: switch (props.test) {
48 case true: {
49 console.log(handlers.value);
@@ -53,8 +53,8 @@ function Component(props) {
53 }
54 }
55
56 - t22 = handlers;
57 - const outerHandlers = t22;
56 + t0 = handlers;
57 + const outerHandlers = t0;
58 return outerHandlers;
59 }
60
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md
+6 -6
@@ -29,17 +29,17 @@ function App(t25) {
29 const { text, hasDeps } = t25;
30
31 hasDeps ? null : [text];
32 - let t18;
32 let t0;
33 + let t1;
34 if ($[0] !== text) {
35 - t0 = text.toUpperCase();
35 + t1 = text.toUpperCase();
36 $[0] = text;
37 - $[1] = t0;
37 + $[1] = t1;
38 } else {
39 - t0 = $[1];
39 + t1 = $[1];
40 }
41 - t18 = t0;
42 - const resolvedText = t18;
41 + t0 = t1;
42 + const resolvedText = t0;
43 return resolvedText;
44 }
45
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md
+9 -9
@@ -20,28 +20,28 @@ function Component(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(4);
23 - let t1;
23 + let t0;
24 if ($[0] !== props) {
25 const x = makeFunction(props);
26 - let t0;
26 + let t1;
27 if ($[2] !== props.text) {
28 - t0 = (
28 + t1 = (
29 <div>
30 <span>{props.text}</span>
31 </div>
32 );
33 $[2] = props.text;
34 - $[3] = t0;
34 + $[3] = t1;
35 } else {
36 - t0 = $[3];
36 + t1 = $[3];
37 }
38 - t1 = x(t0);
38 + t0 = x(t1);
39 $[0] = props;
40 - $[1] = t1;
40 + $[1] = t0;
41 } else {
42 - t1 = $[1];
42 + t0 = $[1];
43 }
44 - const y = t1;
44 + const y = t0;
45 return y;
46 }
47
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-early-return.expect.md
+21 -21
@@ -73,14 +73,14 @@ import { unstable_useMemoCache as useMemoCache } from "react";
73 function ComponentA(props) {
74 const $ = useMemoCache(5);
75 let a_DEBUG;
76 - let t37;
76 + let t0;
77 if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) {
78 - t37 = Symbol.for("react.early_return_sentinel");
78 + t0 = Symbol.for("react.early_return_sentinel");
79 bb7: {
80 a_DEBUG = [];
81 a_DEBUG.push(props.a);
82 if (props.b) {
83 - t37 = null;
83 + t0 = null;
84 break bb7;
85 }
86
@@ -90,13 +90,13 @@ function ComponentA(props) {
90 $[1] = props.b;
91 $[2] = props.d;
92 $[3] = a_DEBUG;
93 - $[4] = t37;
93 + $[4] = t0;
94 } else {
95 a_DEBUG = $[3];
96 - t37 = $[4];
96 + t0 = $[4];
97 }
98 - if (t37 !== Symbol.for("react.early_return_sentinel")) {
99 - return t37;
98 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
99 + return t0;
100 }
101 return a_DEBUG;
102 }
@@ -129,15 +129,15 @@ function ComponentB(props) {
129 function ComponentC(props) {
130 const $ = useMemoCache(3);
131 let a;
132 - let t47;
132 + let t0;
133 if ($[0] !== props) {
134 - t47 = Symbol.for("react.early_return_sentinel");
134 + t0 = Symbol.for("react.early_return_sentinel");
135 bb7: {
136 a = [];
137 a.push(props.a);
138 if (props.b) {
139 a.push(props.c);
140 - t47 = null;
140 + t0 = null;
141 break bb7;
142 }
143
@@ -145,13 +145,13 @@ function ComponentC(props) {
145 }
146 $[0] = props;
147 $[1] = a;
148 - $[2] = t47;
148 + $[2] = t0;
149 } else {
150 a = $[1];
151 - t47 = $[2];
151 + t0 = $[2];
152 }
153 - if (t47 !== Symbol.for("react.early_return_sentinel")) {
154 - return t47;
153 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
154 + return t0;
155 }
156 return a;
157 }
@@ -162,15 +162,15 @@ function ComponentC(props) {
162 function ComponentD(props) {
163 const $ = useMemoCache(3);
164 let a;
165 - let t47;
165 + let t0;
166 if ($[0] !== props) {
167 - t47 = Symbol.for("react.early_return_sentinel");
167 + t0 = Symbol.for("react.early_return_sentinel");
168 bb7: {
169 a = [];
170 a.push(props.a);
171 if (props.b) {
172 a.push(props.c);
173 - t47 = a;
173 + t0 = a;
174 break bb7;
175 }
176
@@ -178,13 +178,13 @@ function ComponentD(props) {
178 }
179 $[0] = props;
180 $[1] = a;
181 - $[2] = t47;
181 + $[2] = t0;
182 } else {
183 a = $[1];
184 - t47 = $[2];
184 + t0 = $[2];
185 }
186 - if (t47 !== Symbol.for("react.early_return_sentinel")) {
187 - return t47;
186 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
187 + return t0;
188 }
189 return a;
190 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/createElement-freeze.expect.md
+9 -9
@@ -37,22 +37,22 @@ function Component(props) {
37 t0 = $[1];
38 }
39 const childProps = t0;
40 - let t2;
40 + let t1;
41 if ($[2] !== childProps) {
42 - let t1;
42 + let t2;
43 if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
44 - t1 = ["hello world"];
45 - $[4] = t1;
44 + t2 = ["hello world"];
45 + $[4] = t2;
46 } else {
47 - t1 = $[4];
47 + t2 = $[4];
48 }
49 - t2 = React.createElement("div", childProps, t1);
49 + t1 = React.createElement("div", childProps, t2);
50 $[2] = childProps;
51 - $[3] = t2;
51 + $[3] = t1;
52 } else {
53 - t2 = $[3];
53 + t1 = $[3];
54 }
55 - const element = t2;
55 + const element = t1;
56 shallowCopy(childProps);
57 return element;
58 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md
+21 -21
@@ -64,29 +64,29 @@ function Component(props) {
64 if ($[0] !== post) {
65 allUrls = [];
66
67 - const { media: t0, comments: t2, urls: t4 } = post;
68 - let t1;
67 + const { media: t0, comments: t1, urls: t2 } = post;
68 + let t3;
69 if ($[4] !== t0) {
70 - t1 = t0 === undefined ? null : t0;
70 + t3 = t0 === undefined ? null : t0;
71 $[4] = t0;
72 - $[5] = t1;
72 + $[5] = t3;
73 } else {
74 - t1 = $[5];
74 + t3 = $[5];
75 }
76 - media = t1;
77 - let t3;
78 - if ($[6] !== t2) {
79 - t3 = t2 === undefined ? [] : t2;
80 - $[6] = t2;
81 - $[7] = t3;
76 + media = t3;
77 + let t4;
78 + if ($[6] !== t1) {
79 + t4 = t1 === undefined ? [] : t1;
80 + $[6] = t1;
81 + $[7] = t4;
82 } else {
83 - t3 = $[7];
83 + t4 = $[7];
84 }
85 - const comments = t3;
85 + const comments = t4;
86 let t5;
87 - if ($[8] !== t4) {
88 - t5 = t4 === undefined ? [] : t4;
89 - $[8] = t4;
87 + if ($[8] !== t2) {
88 + t5 = t2 === undefined ? [] : t2;
89 + $[8] = t2;
90 $[9] = t5;
91 } else {
92 t5 = $[9];
@@ -118,17 +118,17 @@ function Component(props) {
118 allUrls = $[2];
119 onClick = $[3];
120 }
121 - let t7;
121 + let t0;
122 if ($[12] !== media || $[13] !== allUrls || $[14] !== onClick) {
123 - t7 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
123 + t0 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
124 $[12] = media;
125 $[13] = allUrls;
126 $[14] = onClick;
127 - $[15] = t7;
127 + $[15] = t0;
128 } else {
129 - t7 = $[15];
129 + t0 = $[15];
130 }
131 - return t7;
131 + return t0;
132 }
133
134 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md
+12 -12
@@ -37,11 +37,11 @@ function Component(props) {
37 if ($[0] !== post) {
38 const allUrls = [];
39
40 - const { media: t83, comments, urls } = post;
41 - media = t83;
42 - let t0;
40 + const { media: t0, comments, urls } = post;
41 + media = t0;
42 + let t1;
43 if ($[3] !== comments.length) {
44 - t0 = (e) => {
44 + t1 = (e) => {
45 if (!comments.length) {
46 return;
47 }
@@ -49,11 +49,11 @@ function Component(props) {
49 console.log(comments.length);
50 };
51 $[3] = comments.length;
52 - $[4] = t0;
52 + $[4] = t1;
53 } else {
54 - t0 = $[4];
54 + t1 = $[4];
55 }
56 - onClick = t0;
56 + onClick = t1;
57
58 allUrls.push(...urls);
59 $[0] = post;
@@ -63,16 +63,16 @@ function Component(props) {
63 media = $[1];
64 onClick = $[2];
65 }
66 - let t1;
66 + let t0;
67 if ($[5] !== media || $[6] !== onClick) {
68 - t1 = <Media media={media} onClick={onClick} />;
68 + t0 = <Media media={media} onClick={onClick} />;
69 $[5] = media;
70 $[6] = onClick;
71 - $[7] = t1;
71 + $[7] = t0;
72 } else {
73 - t1 = $[7];
73 + t0 = $[7];
74 }
75 - return t1;
75 + return t0;
76 }
77
78 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md
+3 -3
@@ -28,7 +28,7 @@ import * as React from "react";
28
29 function Component(props) {
30 const $ = useMemoCache(2);
31 - let t19;
31 + let t0;
32 let x;
33 if ($[0] !== props.value) {
34 x = [];
@@ -38,8 +38,8 @@ function Component(props) {
38 } else {
39 x = $[1];
40 }
41 - t19 = x;
42 - const x_0 = t19;
41 + t0 = x;
42 + const x_0 = t0;
43 return x_0;
44 }
45
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-nested-early-return-within-reactive-scope.expect.md
+14 -14
@@ -32,29 +32,29 @@ export const FIXTURE_ENTRYPOINT = {
32 import { unstable_useMemoCache as useMemoCache } from "react";
33 function Component(props) {
34 const $ = useMemoCache(5);
35 - let t53;
35 + let t0;
36 if ($[0] !== props) {
37 - t53 = Symbol.for("react.early_return_sentinel");
37 + t0 = Symbol.for("react.early_return_sentinel");
38 bb11: {
39 const x = [];
40 if (props.cond) {
41 x.push(props.a);
42 if (props.b) {
43 - let t0;
43 + let t1;
44 if ($[2] !== props.b) {
45 - t0 = [props.b];
45 + t1 = [props.b];
46 $[2] = props.b;
47 - $[3] = t0;
47 + $[3] = t1;
48 } else {
49 - t0 = $[3];
49 + t1 = $[3];
50 }
51 - const y = t0;
51 + const y = t1;
52 x.push(y);
53 - t53 = x;
53 + t0 = x;
54 break bb11;
55 }
56
57 - t53 = x;
57 + t0 = x;
58 break bb11;
59 } else {
60 let t1;
@@ -64,17 +64,17 @@ function Component(props) {
64 } else {
65 t1 = $[4];
66 }
67 - t53 = t1;
67 + t0 = t1;
68 break bb11;
69 }
70 }
71 $[0] = props;
72 - $[1] = t53;
72 + $[1] = t0;
73 } else {
74 - t53 = $[1];
74 + t0 = $[1];
75 }
76 - if (t53 !== Symbol.for("react.early_return_sentinel")) {
77 - return t53;
76 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
77 + return t0;
78 }
79 }
80
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.expect.md
+12 -12
@@ -70,35 +70,35 @@ let ENABLE_FEATURE = false;
70
71 function Component(props) {
72 const $ = useMemoCache(3);
73 - let t37;
73 + let t0;
74 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
75 - t37 = Symbol.for("react.early_return_sentinel");
75 + t0 = Symbol.for("react.early_return_sentinel");
76 bb8: {
77 const x = [];
78 if (ENABLE_FEATURE) {
79 x.push(42);
80 - t37 = x;
80 + t0 = x;
81 break bb8;
82 } else {
83 console.log("fallthrough");
84 }
85 }
86 - $[0] = t37;
86 + $[0] = t0;
87 } else {
88 - t37 = $[0];
88 + t0 = $[0];
89 }
90 - if (t37 !== Symbol.for("react.early_return_sentinel")) {
91 - return t37;
90 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
91 + return t0;
92 }
93 - let t0;
93 + let t1;
94 if ($[1] !== props.a) {
95 - t0 = makeArray(props.a);
95 + t1 = makeArray(props.a);
96 $[1] = props.a;
97 - $[2] = t0;
97 + $[2] = t1;
98 } else {
99 - t0 = $[2];
99 + t1 = $[2];
100 }
101 - return t0;
101 + return t1;
102 }
103
104 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-within-reactive-scope.expect.md
+12 -12
@@ -46,35 +46,35 @@ import { makeArray } from "shared-runtime";
46
47 function Component(props) {
48 const $ = useMemoCache(4);
49 - let t33;
49 + let t0;
50 if ($[0] !== props) {
51 - t33 = Symbol.for("react.early_return_sentinel");
51 + t0 = Symbol.for("react.early_return_sentinel");
52 bb8: {
53 const x = [];
54 if (props.cond) {
55 x.push(props.a);
56 - t33 = x;
56 + t0 = x;
57 break bb8;
58 } else {
59 - let t0;
59 + let t1;
60 if ($[2] !== props.b) {
61 - t0 = makeArray(props.b);
61 + t1 = makeArray(props.b);
62 $[2] = props.b;
63 - $[3] = t0;
63 + $[3] = t1;
64 } else {
65 - t0 = $[3];
65 + t1 = $[3];
66 }
67 - t33 = t0;
67 + t0 = t1;
68 break bb8;
69 }
70 }
71 $[0] = props;
72 - $[1] = t33;
72 + $[1] = t0;
73 } else {
74 - t33 = $[1];
74 + t0 = $[1];
75 }
76 - if (t33 !== Symbol.for("react.early_return_sentinel")) {
77 - return t33;
76 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
77 + return t0;
78 }
79 }
80
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md
+4 -4
@@ -26,8 +26,8 @@ function Component(props) {
26 const $ = useMemoCache(7);
27 let b;
28 if ($[0] !== props.a) {
29 - const { a, ...t29 } = props.a;
30 - b = t29;
29 + const { a, ...t0 } = props.a;
30 + b = t0;
31 $[0] = props.a;
32 $[1] = b;
33 } else {
@@ -35,8 +35,8 @@ function Component(props) {
35 }
36 let d;
37 if ($[2] !== props.c) {
38 - const [c, ...t30] = props.c;
39 - d = t30;
38 + const [c, ...t0] = props.c;
39 + d = t0;
40 $[2] = props.c;
41 $[3] = d;
42 } else {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md
+16 -16
@@ -50,35 +50,35 @@ function Component() {
50 const [state] = React$useState(0);
51 const object = Internal$Reassigned$useHook();
52 const json = JSON.stringify(object);
53 - let t25;
53 let t0;
54 + let t1;
55 if ($[0] !== state) {
56 - t25 = makeArray(state);
57 - const doubledArray = t25;
56 + t0 = makeArray(state);
57 + const doubledArray = t0;
58
59 - t0 = doubledArray.join("");
59 + t1 = doubledArray.join("");
60 $[0] = state;
61 - $[1] = t0;
62 - $[2] = t25;
61 + $[1] = t1;
62 + $[2] = t0;
63 } else {
64 - t0 = $[1];
65 - t25 = $[2];
64 + t1 = $[1];
65 + t0 = $[2];
66 }
67 - let t1;
68 - if ($[3] !== t0 || $[4] !== json) {
69 - t1 = (
67 + let t2;
68 + if ($[3] !== t1 || $[4] !== json) {
69 + t2 = (
70 <div>
71 - {t0}
71 + {t1}
72 {json}
73 </div>
74 );
75 - $[3] = t0;
75 + $[3] = t1;
76 $[4] = json;
77 - $[5] = t1;
77 + $[5] = t2;
78 } else {
79 - t1 = $[5];
79 + t2 = $[5];
80 }
81 - return t1;
81 + return t2;
82 }
83
84 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-logical.expect.md
+5 -5
@@ -27,19 +27,19 @@ import { getNull } from "shared-runtime";
27
28 function Component(props) {
29 const $ = useMemoCache(3);
30 - let t10;
30 + let t0;
31 let items;
32 if ($[0] !== props.a) {
33 - t10 = getNull() ?? [];
34 - items = t10;
33 + t0 = getNull() ?? [];
34 + items = t0;
35
36 items.push(props.a);
37 $[0] = props.a;
38 $[1] = items;
39 - $[2] = t10;
39 + $[2] = t0;
40 } else {
41 items = $[1];
42 - t10 = $[2];
42 + t0 = $[2];
43 }
44 return items;
45 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md
+4 -4
@@ -29,13 +29,13 @@ function Component(props) {
29 const $ = useMemoCache(2);
30 let items;
31 if ($[0] !== props) {
32 - let t9;
32 + let t0;
33 if (props.cond) {
34 - t9 = [];
34 + t0 = [];
35 } else {
36 - t9 = null;
36 + t0 = null;
37 }
38 - items = t9;
38 + items = t0;
39
40 items?.push(props.a);
41 $[0] = props;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later.expect.md
+5 -5
@@ -23,19 +23,19 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(3);
26 - let t4;
26 + let t0;
27 let items;
28 if ($[0] !== props.a) {
29 - t4 = [];
30 - items = t4;
29 + t0 = [];
30 + items = t0;
31
32 items.push(props.a);
33 $[0] = props.a;
34 $[1] = items;
35 - $[2] = t4;
35 + $[2] = t0;
36 } else {
37 items = $[1];
38 - t4 = $[2];
38 + t0 = $[2];
39 }
40 return items;
41 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
+43 -43
@@ -27,66 +27,66 @@ function Component(props) {
27 const $ = useMemoCache(15);
28 const item = useFragment(FRAGMENT, props.item);
29 useFreeze(item);
30 - let t1;
31 - let T2;
30 let t0;
33 - let T3;
31 + let T0;
32 + let t1;
33 + let T1;
34 if ($[0] !== item) {
35 const count = new MaybeMutable(item);
36
37 - T3 = View;
38 - T2 = View;
37 + T1 = View;
38 + T0 = View;
39 if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
40 - t0 = <span>Text</span>;
41 - $[5] = t0;
40 + t1 = <span>Text</span>;
41 + $[5] = t1;
42 } else {
43 - t0 = $[5];
43 + t1 = $[5];
44 }
45 - t1 = maybeMutate(count);
45 + t0 = maybeMutate(count);
46 $[0] = item;
47 - $[1] = t1;
48 - $[2] = T2;
49 - $[3] = t0;
50 - $[4] = T3;
47 + $[1] = t0;
48 + $[2] = T0;
49 + $[3] = t1;
50 + $[4] = T1;
51 } else {
52 - t1 = $[1];
53 - T2 = $[2];
54 - t0 = $[3];
55 - T3 = $[4];
52 + t0 = $[1];
53 + T0 = $[2];
54 + t1 = $[3];
55 + T1 = $[4];
56 }
57 - let t4;
58 - if ($[6] !== t1) {
59 - t4 = <span>{t1}</span>;
60 - $[6] = t1;
61 - $[7] = t4;
57 + let t2;
58 + if ($[6] !== t0) {
59 + t2 = <span>{t0}</span>;
60 + $[6] = t0;
61 + $[7] = t2;
62 } else {
63 - t4 = $[7];
63 + t2 = $[7];
64 }
65 - let t5;
66 - if ($[8] !== T2 || $[9] !== t0 || $[10] !== t4) {
67 - t5 = (
68 - <T2>
69 - {t0}
70 - {t4}
71 - </T2>
65 + let t3;
66 + if ($[8] !== T0 || $[9] !== t1 || $[10] !== t2) {
67 + t3 = (
68 + <T0>
69 + {t1}
70 + {t2}
71 + </T0>
72 );
73 - $[8] = T2;
74 - $[9] = t0;
75 - $[10] = t4;
76 - $[11] = t5;
73 + $[8] = T0;
74 + $[9] = t1;
75 + $[10] = t2;
76 + $[11] = t3;
77 } else {
78 - t5 = $[11];
78 + t3 = $[11];
79 }
80 - let t6;
81 - if ($[12] !== T3 || $[13] !== t5) {
82 - t6 = <T3>{t5}</T3>;
83 - $[12] = T3;
84 - $[13] = t5;
85 - $[14] = t6;
80 + let t4;
81 + if ($[12] !== T1 || $[13] !== t3) {
82 + t4 = <T1>{t3}</T1>;
83 + $[12] = T1;
84 + $[13] = t3;
85 + $[14] = t4;
86 } else {
87 - t6 = $[14];
87 + t4 = $[14];
88 }
89 - return t6;
89 + return t4;
90 }
91
92 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md
+17 -17
@@ -55,47 +55,47 @@ function Component(props) {
55 const $ = useMemoCache(11);
56 let Tag;
57 let T0;
58 - let t1;
58 + let t0;
59 if ($[0] !== props.component || $[1] !== props.alternateComponent) {
60 const maybeMutable = new MaybeMutable();
61 Tag = props.component;
62
63 T0 = Tag;
64 - t1 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
64 + t0 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
65 $[0] = props.component;
66 $[1] = props.alternateComponent;
67 $[2] = Tag;
68 $[3] = T0;
69 - $[4] = t1;
69 + $[4] = t0;
70 } else {
71 Tag = $[2];
72 T0 = $[3];
73 - t1 = $[4];
73 + t0 = $[4];
74 }
75 - let t2;
75 + let t1;
76 if ($[5] !== Tag) {
77 - t2 = <Tag />;
77 + t1 = <Tag />;
78 $[5] = Tag;
79 - $[6] = t2;
79 + $[6] = t1;
80 } else {
81 - t2 = $[6];
81 + t1 = $[6];
82 }
83 - let t3;
84 - if ($[7] !== T0 || $[8] !== t1 || $[9] !== t2) {
85 - t3 = (
83 + let t2;
84 + if ($[7] !== T0 || $[8] !== t0 || $[9] !== t1) {
85 + t2 = (
86 <T0>
87 + {t0}
88 {t1}
88 - {t2}
89 </T0>
90 );
91 $[7] = T0;
92 - $[8] = t1;
93 - $[9] = t2;
94 - $[10] = t3;
92 + $[8] = t0;
93 + $[9] = t1;
94 + $[10] = t2;
95 } else {
96 - t3 = $[10];
96 + t2 = $[10];
97 }
98 - return t3;
98 + return t2;
99 }
100
101 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md
+8 -8
@@ -31,23 +31,23 @@ import { StaticText1, StaticText2 } from "shared-runtime";
31 function Component(props) {
32 const $ = useMemoCache(3);
33
34 - const t1 = props.value;
35 - let t0;
34 + const t0 = props.value;
35 + let t1;
36 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37 - t0 = <StaticText2 />;
38 - $[0] = t0;
37 + t1 = <StaticText2 />;
38 + $[0] = t1;
39 } else {
40 - t0 = $[0];
40 + t1 = $[0];
41 }
42 let t2;
43 - if ($[1] !== t1) {
43 + if ($[1] !== t0) {
44 t2 = (
45 <StaticText1>
46 - {t1}
46 {t0}
47 + {t1}
48 </StaticText1>
49 );
50 - $[1] = t1;
50 + $[1] = t0;
51 $[2] = t2;
52 } else {
53 t2 = $[2];
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md
+6 -6
@@ -25,19 +25,19 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function Foo() {
27 const $ = useMemoCache(1);
28 - let t18;
28 let t0;
29 + let t1;
30 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31 - t0 = function a(t28) {
31 + t1 = function a(t28) {
32 const x_0 = t28 === undefined ? () => {} : t28;
33 return x_0;
34 };
35 - $[0] = t0;
35 + $[0] = t1;
36 } else {
37 - t0 = $[0];
37 + t1 = $[0];
38 }
39 - t18 = t0;
40 - return t18;
39 + t0 = t1;
40 + return t0;
41 }
42
43 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md
+9 -9
@@ -34,22 +34,22 @@ export const FIXTURE_ENTRYPOINT = {
34 import { unstable_useMemoCache as useMemoCache } from "react";
35 function Component(props) {
36 const $ = useMemoCache(3);
37 - let t1;
37 + let t0;
38 if ($[0] !== props.items) {
39 - let t0;
39 + let t1;
40 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
41 - t0 = (item) => item != null;
42 - $[2] = t0;
41 + t1 = (item) => item != null;
42 + $[2] = t1;
43 } else {
44 - t0 = $[2];
44 + t1 = $[2];
45 }
46 - t1 = props.items.filter(t0);
46 + t0 = props.items.filter(t1);
47 $[0] = props.items;
48 - $[1] = t1;
48 + $[1] = t0;
49 } else {
50 - t1 = $[1];
50 + t0 = $[1];
51 }
52 - const filtered = t1;
52 + const filtered = t0;
53 return filtered;
54 }
55
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md
+5 -5
@@ -33,15 +33,15 @@ function foo(a, b, c, d) {
33 }
34 x = t0;
35 } else {
36 - let t1;
36 + let t0;
37 if ($[2] !== c) {
38 - t1 = { c };
38 + t0 = { c };
39 $[2] = c;
40 - $[3] = t1;
40 + $[3] = t0;
41 } else {
42 - t1 = $[3];
42 + t0 = $[3];
43 }
44 - x = t1;
44 + x = t0;
45 }
46 return x;
47 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md
+10 -10
@@ -38,31 +38,31 @@ function useHook(t16) {
38 } else {
39 t0 = $[1];
40 }
41 - let t2;
41 + let t1;
42 if ($[2] !== b || $[3] !== c || $[4] !== t0) {
43 - let t1;
43 + let t2;
44 if ($[6] !== c) {
45 - t1 = { c };
45 + t2 = { c };
46 $[6] = c;
47 - $[7] = t1;
47 + $[7] = t2;
48 } else {
49 - t1 = $[7];
49 + t2 = $[7];
50 }
51 - t2 = {
51 + t1 = {
52 x: t0,
53 y() {
54 return [b];
55 },
56 - z: t1,
56 + z: t2,
57 };
58 $[2] = b;
59 $[3] = c;
60 $[4] = t0;
61 - $[5] = t2;
61 + $[5] = t1;
62 } else {
63 - t2 = $[5];
63 + t1 = $[5];
64 }
65 - return t2;
65 + return t1;
66 }
67
68 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/partial-early-return-within-reactive-scope.expect.md
+13 -13
@@ -32,39 +32,39 @@ import { unstable_useMemoCache as useMemoCache } from "react";
32 function Component(props) {
33 const $ = useMemoCache(4);
34 let y;
35 - let t46;
35 + let t0;
36 if ($[0] !== props) {
37 - t46 = Symbol.for("react.early_return_sentinel");
37 + t0 = Symbol.for("react.early_return_sentinel");
38 bb11: {
39 const x = [];
40 if (props.cond) {
41 x.push(props.a);
42 - t46 = x;
42 + t0 = x;
43 break bb11;
44 } else {
45 - let t0;
45 + let t1;
46 if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47 - t0 = foo();
48 - $[3] = t0;
47 + t1 = foo();
48 + $[3] = t1;
49 } else {
50 - t0 = $[3];
50 + t1 = $[3];
51 }
52 - y = t0;
52 + y = t1;
53 if (props.b) {
54 - t46 = undefined;
54 + t0 = undefined;
55 break bb11;
56 }
57 }
58 }
59 $[0] = props;
60 $[1] = y;
61 - $[2] = t46;
61 + $[2] = t0;
62 } else {
63 y = $[1];
64 - t46 = $[2];
64 + t0 = $[2];
65 }
66 - if (t46 !== Symbol.for("react.early_return_sentinel")) {
67 - return t46;
66 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
67 + return t0;
68 }
69 return y;
70 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md
+5 -5
@@ -51,16 +51,16 @@ function PrimitiveAsDepNested(props) {
51 x = $[2];
52 y = $[3];
53 }
54 - let t2;
54 + let t0;
55 if ($[6] !== x || $[7] !== y) {
56 - t2 = [x, y];
56 + t0 = [x, y];
57 $[6] = x;
58 $[7] = y;
59 - $[8] = t2;
59 + $[8] = t0;
60 } else {
61 - t2 = $[8];
61 + t0 = $[8];
62 }
63 - return t2;
63 + return t0;
64 }
65
66 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md
+5 -5
@@ -46,15 +46,15 @@ function Component(props) {
46 }
47 const count = posts.length;
48 foo(count);
49 - let t1;
49 + let t0;
50 if ($[3] !== posts) {
51 - t1 = <>{posts}</>;
51 + t0 = <>{posts}</>;
52 $[3] = posts;
53 - $[4] = t1;
53 + $[4] = t0;
54 } else {
55 - t1 = $[4];
55 + t0 = $[4];
56 }
57 - return t1;
57 + return t0;
58 }
59
60 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md
+5 -5
@@ -51,16 +51,16 @@ function Component(props) {
51 x = $[3];
52 y = $[4];
53 }
54 - let t1;
54 + let t0;
55 if ($[6] !== x || $[7] !== y) {
56 - t1 = <Component x={x} y={y} />;
56 + t0 = <Component x={x} y={y} />;
57 $[6] = x;
58 $[7] = y;
59 - $[8] = t1;
59 + $[8] = t0;
60 } else {
61 - t1 = $[8];
61 + t0 = $[8];
62 }
63 - return t1;
63 + return t0;
64 }
65
66 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md
+5 -5
@@ -47,16 +47,16 @@ function Component(props) {
47 x = $[2];
48 y = $[3];
49 }
50 - let t1;
50 + let t0;
51 if ($[5] !== x || $[6] !== y) {
52 - t1 = <Component x={x} y={y} />;
52 + t0 = <Component x={x} y={y} />;
53 $[5] = x;
54 $[6] = y;
55 - $[7] = t1;
55 + $[7] = t0;
56 } else {
57 - t1 = $[7];
57 + t0 = $[7];
58 }
59 - return t1;
59 + return t0;
60 }
61
62 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md
+5 -5
@@ -44,14 +44,14 @@ function Component(props) {
44 }
45 return t1;
46 }
47 - let t2;
47 + let t1;
48 if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
49 - t2 = <div>Default</div>;
50 - $[3] = t2;
49 + t1 = <div>Default</div>;
50 + $[3] = t1;
51 } else {
52 - t2 = $[3];
52 + t1 = $[3];
53 }
54 - return t2;
54 + return t1;
55 }
56
57 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md
+3 -3
@@ -28,11 +28,11 @@ function Component(props) {
28 };
29
30 const object = { x, onChange };
31 - let t43;
31 + let t0;
32
33 const { x: x_0, onChange: onChange_0 } = object;
34 - t43 = <input value={x_0} onChange={onChange_0} />;
35 - return t43;
34 + t0 = <input value={x_0} onChange={onChange_0} />;
35 + return t0;
36 }
37
38 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dont-memoize-array-with-mutable-map-after-hook.expect.md
+8 -8
@@ -62,27 +62,27 @@ function Component(props) {
62
63 let y;
64
65 - const t3 = x.map((item) => {
65 + const t2 = x.map((item) => {
66 item.flag = true;
67 return <span key={item.id}>{item.text}</span>;
68 });
69 - let t2;
69 + let t3;
70 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
71 - t2 = mutate(y);
72 - $[2] = t2;
71 + t3 = mutate(y);
72 + $[2] = t3;
73 } else {
74 - t2 = $[2];
74 + t3 = $[2];
75 }
76 let t4;
77 - if ($[3] !== onClick || $[4] !== t3) {
77 + if ($[3] !== onClick || $[4] !== t2) {
78 t4 = (
79 <div onClick={onClick}>
80 - {t3}
80 {t2}
81 + {t3}
82 </div>
83 );
84 $[3] = onClick;
85 - $[4] = t3;
85 + $[4] = t2;
86 $[5] = t4;
87 } else {
88 t4 = $[5];
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-hoisting-variable-collision.expect.md
+14 -14
@@ -21,31 +21,31 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(5);
24 - let t1;
24 + let t0;
25 if ($[0] !== props.items) {
26 - let t0;
26 + let t1;
27 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
28 - t0 = (x) => x;
29 - $[2] = t0;
28 + t1 = (x) => x;
29 + $[2] = t1;
30 } else {
31 - t0 = $[2];
31 + t1 = $[2];
32 }
33 - t1 = props.items.map(t0);
33 + t0 = props.items.map(t1);
34 $[0] = props.items;
35 - $[1] = t1;
35 + $[1] = t0;
36 } else {
37 - t1 = $[1];
37 + t0 = $[1];
38 }
39 - const items = t1;
40 - let t2;
39 + const items = t0;
40 + let t1;
41 if ($[3] !== items) {
42 - t2 = [42, items];
42 + t1 = [42, items];
43 $[3] = items;
44 - $[4] = t2;
44 + $[4] = t1;
45 } else {
46 - t2 = $[4];
46 + t1 = $[4];
47 }
48 - return t2;
48 + return t1;
49 }
50
51 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md
+5 -5
@@ -60,16 +60,16 @@ function Component(a, b) {
60 x = $[4];
61 y = $[5];
62 }
63 - let t3;
63 + let t2;
64 if ($[8] !== x || $[9] !== y) {
65 - t3 = [x, y];
65 + t2 = [x, y];
66 $[8] = x;
67 $[9] = y;
68 - $[10] = t3;
68 + $[10] = t2;
69 } else {
70 - t3 = $[10];
70 + t2 = $[10];
71 }
72 - return t3;
72 + return t2;
73 }
74
75 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md
+84 -84
@@ -46,123 +46,123 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
46
47 function Component(props) {
48 const $ = useMemoCache(29);
49 - let t10;
49 let t0;
51 - let t92;
50 + let t1;
51 + let t2;
52 if ($[0] !== props) {
53 - t92 = Symbol.for("react.early_return_sentinel");
53 + t2 = Symbol.for("react.early_return_sentinel");
54 bb10: {
55 - t10 = toJSON(props);
56 - const propsString = t10;
55 + t0 = toJSON(props);
56 + const propsString = t0;
57 if (propsString.length <= 2) {
58 - t92 = null;
58 + t2 = null;
59 break bb10;
60 }
61
62 - t0 = identity(propsString);
62 + t1 = identity(propsString);
63 }
64 $[0] = props;
65 - $[1] = t0;
66 - $[2] = t92;
67 - $[3] = t10;
65 + $[1] = t1;
66 + $[2] = t2;
67 + $[3] = t0;
68 } else {
69 - t0 = $[1];
70 - t92 = $[2];
71 - t10 = $[3];
69 + t1 = $[1];
70 + t2 = $[2];
71 + t0 = $[3];
72 }
73 - if (t92 !== Symbol.for("react.early_return_sentinel")) {
74 - return t92;
73 + if (t2 !== Symbol.for("react.early_return_sentinel")) {
74 + return t2;
75 }
76 - let t1;
77 - if ($[4] !== t0) {
78 - t1 = { url: t0 };
79 - $[4] = t0;
80 - $[5] = t1;
76 + let t3;
77 + if ($[4] !== t1) {
78 + t3 = { url: t1 };
79 + $[4] = t1;
80 + $[5] = t3;
81 } else {
82 - t1 = $[5];
82 + t3 = $[5];
83 }
84 - const linkProps = t1;
85 - let T7;
86 - let t8;
87 - let t2;
88 - let t3;
84 + const linkProps = t3;
85 + let T0;
86 let t4;
87 let t5;
88 let t6;
89 + let t7;
90 + let t8;
91 let t9;
92 + let t10;
93 if ($[6] !== linkProps) {
94 const x = {};
95
96 - T7 = Stringify;
97 - t8 = linkProps;
96 + T0 = Stringify;
97 + t4 = linkProps;
98 if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
99 - t2 = [1];
100 - t3 = [2];
101 - t4 = [3];
102 - t5 = [4];
103 - t6 = [5];
104 - $[15] = t2;
105 - $[16] = t3;
106 - $[17] = t4;
107 - $[18] = t5;
108 - $[19] = t6;
99 + t5 = [1];
100 + t6 = [2];
101 + t7 = [3];
102 + t8 = [4];
103 + t9 = [5];
104 + $[15] = t5;
105 + $[16] = t6;
106 + $[17] = t7;
107 + $[18] = t8;
108 + $[19] = t9;
109 } else {
110 - t2 = $[15];
111 - t3 = $[16];
112 - t4 = $[17];
113 - t5 = $[18];
114 - t6 = $[19];
110 + t5 = $[15];
111 + t6 = $[16];
112 + t7 = $[17];
113 + t8 = $[18];
114 + t9 = $[19];
115 }
116
117 - t9 = makeArray(x, 2);
117 + t10 = makeArray(x, 2);
118 $[6] = linkProps;
119 - $[7] = T7;
120 - $[8] = t8;
121 - $[9] = t2;
122 - $[10] = t3;
123 - $[11] = t4;
124 - $[12] = t5;
125 - $[13] = t6;
126 - $[14] = t9;
119 + $[7] = T0;
120 + $[8] = t4;
121 + $[9] = t5;
122 + $[10] = t6;
123 + $[11] = t7;
124 + $[12] = t8;
125 + $[13] = t9;
126 + $[14] = t10;
127 } else {
128 - T7 = $[7];
129 - t8 = $[8];
130 - t2 = $[9];
131 - t3 = $[10];
132 - t4 = $[11];
133 - t5 = $[12];
134 - t6 = $[13];
135 - t9 = $[14];
128 + T0 = $[7];
129 + t4 = $[8];
130 + t5 = $[9];
131 + t6 = $[10];
132 + t7 = $[11];
133 + t8 = $[12];
134 + t9 = $[13];
135 + t10 = $[14];
136 }
137 - let t10$0;
137 + let t11;
138 if (
139 - $[20] !== T7 ||
140 - $[21] !== t8 ||
141 - $[22] !== t2 ||
142 - $[23] !== t3 ||
143 - $[24] !== t4 ||
144 - $[25] !== t5 ||
145 - $[26] !== t6 ||
146 - $[27] !== t9
139 + $[20] !== T0 ||
140 + $[21] !== t4 ||
141 + $[22] !== t5 ||
142 + $[23] !== t6 ||
143 + $[24] !== t7 ||
144 + $[25] !== t8 ||
145 + $[26] !== t9 ||
146 + $[27] !== t10
147 ) {
148 - t10$0 = (
149 - <T7 link={t8} val1={t2} val2={t3} val3={t4} val4={t5} val5={t6}>
150 - {t9}
151 - </T7>
148 + t11 = (
149 + <T0 link={t4} val1={t5} val2={t6} val3={t7} val4={t8} val5={t9}>
150 + {t10}
151 + </T0>
152 );
153 - $[20] = T7;
154 - $[21] = t8;
155 - $[22] = t2;
156 - $[23] = t3;
157 - $[24] = t4;
158 - $[25] = t5;
159 - $[26] = t6;
160 - $[27] = t9;
161 - $[28] = t10$0;
153 + $[20] = T0;
154 + $[21] = t4;
155 + $[22] = t5;
156 + $[23] = t6;
157 + $[24] = t7;
158 + $[25] = t8;
159 + $[26] = t9;
160 + $[27] = t10;
161 + $[28] = t11;
162 } else {
163 - t10$0 = $[28];
163 + t11 = $[28];
164 }
165 - return t10$0;
165 + return t11;
166 }
167
168 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md
+16 -16
@@ -52,18 +52,18 @@ function Component(props) {
52 const { buttons } = props;
53 let nonPrimaryButtons;
54 if ($[0] !== buttons) {
55 - const [primaryButton, ...t79] = buttons;
56 - nonPrimaryButtons = t79;
55 + const [primaryButton, ...t0] = buttons;
56 + nonPrimaryButtons = t0;
57 $[0] = buttons;
58 $[1] = nonPrimaryButtons;
59 } else {
60 nonPrimaryButtons = $[1];
61 }
62 - let t1;
62 + let t0;
63 if ($[2] !== nonPrimaryButtons) {
64 - let t0;
64 + let t1;
65 if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
66 - t0 = (buttonProps, i) => (
66 + t1 = (buttonProps, i) => (
67 <Stringify
68 {...buttonProps}
69 key={`button-${i}`}
@@ -74,26 +74,26 @@ function Component(props) {
74 }
75 />
76 );
77 - $[4] = t0;
77 + $[4] = t1;
78 } else {
79 - t0 = $[4];
79 + t1 = $[4];
80 }
81 - t1 = nonPrimaryButtons.map(t0);
81 + t0 = nonPrimaryButtons.map(t1);
82 $[2] = nonPrimaryButtons;
83 - $[3] = t1;
83 + $[3] = t0;
84 } else {
85 - t1 = $[3];
85 + t0 = $[3];
86 }
87 - const renderedNonPrimaryButtons = t1;
88 - let t2;
87 + const renderedNonPrimaryButtons = t0;
88 + let t1;
89 if ($[5] !== renderedNonPrimaryButtons) {
90 - t2 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
90 + t1 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
91 $[5] = renderedNonPrimaryButtons;
92 - $[6] = t2;
92 + $[6] = t1;
93 } else {
94 - t2 = $[6];
94 + t1 = $[6];
95 }
96 - return t2;
96 + return t1;
97 }
98
99 const styles = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md
+5 -5
@@ -51,20 +51,20 @@ function Component(props) {
51
52 const y = useFeature;
53 const z = useFeature.useProperty;
54 - let t1;
54 + let t0;
55 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
56 - t1 = (
56 + t0 = (
57 <Stringify val={useFeature}>
58 {x}
59 {y}
60 {z}
61 </Stringify>
62 );
63 - $[1] = t1;
63 + $[1] = t0;
64 } else {
65 - t1 = $[1];
65 + t0 = $[1];
66 }
67 - return t1;
67 + return t0;
68 }
69
70 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md
+5 -5
@@ -53,9 +53,9 @@ function Component(t29) {
53
54 const y = useFeature;
55 const z = useFeature.useProperty;
56 - let t2;
56 + let t0;
57 if ($[3] !== useFeature || $[4] !== x || $[5] !== y || $[6] !== z) {
58 - t2 = (
58 + t0 = (
59 <Stringify val={useFeature}>
60 {x}
61 {y}
@@ -66,11 +66,11 @@ function Component(t29) {
66 $[4] = x;
67 $[5] = y;
68 $[6] = z;
69 - $[7] = t2;
69 + $[7] = t0;
70 } else {
71 - t2 = $[7];
71 + t0 = $[7];
72 }
73 - return t2;
73 + return t0;
74 }
75
76 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md
+2 -2
@@ -47,8 +47,8 @@ function Component(statusName) {
47 let t0;
48 let t1;
49 if ($[0] !== statusName) {
50 - const { status, text: t47 } = foo(statusName);
51 - text = t47;
50 + const { status, text: t2 } = foo(statusName);
51 + text = t2;
52 const { bg, color } = getStyles(status);
53
54 t1 = identity(bg);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md
+4 -4
@@ -50,11 +50,11 @@ function Component(statusName) {
50 let text;
51 let font;
52 if ($[0] !== statusName) {
53 - const { status, text: t49 } = foo(statusName);
54 - text = t49;
53 + const { status, text: t1 } = foo(statusName);
54 + text = t1;
55
56 - const { color, font: t50 } = getStyles(status);
57 - font = t50;
56 + const { color, font: t2 } = getStyles(status);
57 + font = t2;
58
59 t0 = identity(color);
60 $[0] = statusName;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md
+8 -8
@@ -29,16 +29,16 @@ export default function foo(x, y) {
29 return t0;
30 }
31
32 - const t1 = y * 10;
33 - let t2;
34 - if ($[2] !== t1) {
35 - t2 = [t1];
36 - $[2] = t1;
37 - $[3] = t2;
32 + const t0 = y * 10;
33 + let t1;
34 + if ($[2] !== t0) {
35 + t1 = [t0];
36 + $[2] = t0;
37 + $[3] = t1;
38 } else {
39 - t2 = $[3];
39 + t1 = $[3];
40 }
41 - return t2;
41 + return t1;
42 }
43
44 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md
+5 -5
@@ -42,14 +42,14 @@ function foo(a) {
42 const y = t0;
43 x.y = y;
44 } else {
45 - let t1;
45 + let t0;
46 if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47 - t1 = {};
48 - $[3] = t1;
47 + t0 = {};
48 + $[3] = t0;
49 } else {
50 - t1 = $[3];
50 + t0 = $[3];
51 }
52 - const z = t1;
52 + const z = t0;
53 x.z = z;
54 }
55 $[0] = a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md
+10 -10
@@ -67,26 +67,26 @@ function Component(props) {
67 x = $[1];
68 y = $[2];
69 }
70 - let t1;
70 + let t0;
71 if ($[4] !== x) {
72 - t1 = <Component data={x} />;
72 + t0 = <Component data={x} />;
73 $[4] = x;
74 - $[5] = t1;
74 + $[5] = t0;
75 } else {
76 - t1 = $[5];
76 + t0 = $[5];
77 }
78 - const child = t1;
78 + const child = t0;
79 y.push(props.p4);
80 - let t2;
80 + let t1;
81 if ($[6] !== y || $[7] !== child) {
82 - t2 = <Component data={y}>{child}</Component>;
82 + t1 = <Component data={y}>{child}</Component>;
83 $[6] = y;
84 $[7] = child;
85 - $[8] = t2;
85 + $[8] = t1;
86 } else {
87 - t2 = $[8];
87 + t1 = $[8];
88 }
89 - return t2;
89 + return t1;
90 }
91
92 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo.unnecessary-lambda-memoization.expect.md
+14 -14
@@ -26,31 +26,31 @@ import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(props) {
27 const $ = useMemoCache(5);
28 const data = useFreeze();
29 - let t1;
29 + let t0;
30 if ($[0] !== data.items) {
31 - let t0;
31 + let t1;
32 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
33 - t0 = (item) => <Item item={item} />;
34 - $[2] = t0;
33 + t1 = (item) => <Item item={item} />;
34 + $[2] = t1;
35 } else {
36 - t0 = $[2];
36 + t1 = $[2];
37 }
38 - t1 = data.items.map(t0);
38 + t0 = data.items.map(t1);
39 $[0] = data.items;
40 - $[1] = t1;
40 + $[1] = t0;
41 } else {
42 - t1 = $[1];
42 + t0 = $[1];
43 }
44 - const items = t1;
45 - let t2;
44 + const items = t0;
45 + let t1;
46 if ($[3] !== items) {
47 - t2 = <div>{items}</div>;
47 + t1 = <div>{items}</div>;
48 $[3] = items;
49 - $[4] = t2;
49 + $[4] = t1;
50 } else {
51 - t2 = $[4];
51 + t1 = $[4];
52 }
53 - return t2;
53 + return t1;
54 }
55
56 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md
+9 -9
@@ -72,22 +72,22 @@ function Component(props) {
72 t2 = $[6];
73 }
74 useEffect(t1, t2);
75 - let t4;
75 + let t3;
76 if ($[7] !== data) {
77 - let t3;
77 + let t4;
78 if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
79 - t3 = (x) => x;
80 - $[9] = t3;
79 + t4 = (x) => x;
80 + $[9] = t4;
81 } else {
82 - t3 = $[9];
82 + t4 = $[9];
83 }
84 - t4 = data.map(t3);
84 + t3 = data.map(t4);
85 $[7] = data;
86 - $[8] = t4;
86 + $[8] = t3;
87 } else {
88 - t4 = $[8];
88 + t3 = $[8];
89 }
90 - const items = t4;
90 + const items = t3;
91 return items;
92 }
93
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md
+8 -8
@@ -31,9 +31,9 @@ const { throwInput } = require("shared-runtime");
31
32 function Component(props) {
33 const $ = useMemoCache(3);
34 - let t49;
34 + let t0;
35 if ($[0] !== props.y || $[1] !== props.e) {
36 - t49 = Symbol.for("react.early_return_sentinel");
36 + t0 = Symbol.for("react.early_return_sentinel");
37 bb18: {
38 try {
39 const y = [];
@@ -42,21 +42,21 @@ function Component(props) {
42 } catch (t25) {
43 const e = t25;
44 e.push(props.e);
45 - t49 = e;
45 + t0 = e;
46 break bb18;
47 }
48
49 - t49 = null;
49 + t0 = null;
50 break bb18;
51 }
52 $[0] = props.y;
53 $[1] = props.e;
54 - $[2] = t49;
54 + $[2] = t0;
55 } else {
56 - t49 = $[2];
56 + t0 = $[2];
57 }
58 - if (t49 !== Symbol.for("react.early_return_sentinel")) {
59 - return t49;
58 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
59 + return t0;
60 }
61 }
62
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md
+8 -8
@@ -32,9 +32,9 @@ const { throwInput } = require("shared-runtime");
32
33 function Component(props) {
34 const $ = useMemoCache(1);
35 - let t36;
35 + let t0;
36 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37 - t36 = Symbol.for("react.early_return_sentinel");
37 + t0 = Symbol.for("react.early_return_sentinel");
38 bb11: {
39 const x = [];
40 try {
@@ -42,19 +42,19 @@ function Component(props) {
42 } catch (t22) {
43 const e = t22;
44 e.push(null);
45 - t36 = e;
45 + t0 = e;
46 break bb11;
47 }
48
49 - t36 = x;
49 + t0 = x;
50 break bb11;
51 }
52 - $[0] = t36;
52 + $[0] = t0;
53 } else {
54 - t36 = $[0];
54 + t0 = $[0];
55 }
56 - if (t36 !== Symbol.for("react.early_return_sentinel")) {
57 - return t36;
56 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
57 + return t0;
58 }
59 }
60
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-return.expect.md
+8 -8
@@ -34,32 +34,32 @@ const { shallowCopy, throwInput } = require("shared-runtime");
34 function Component(props) {
35 const $ = useMemoCache(2);
36 let x;
37 - let t43;
37 + let t0;
38 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
39 - t43 = Symbol.for("react.early_return_sentinel");
39 + t0 = Symbol.for("react.early_return_sentinel");
40 bb25: {
41 x = [];
42 try {
43 const y = shallowCopy({});
44 if (y == null) {
45 - t43 = undefined;
45 + t0 = undefined;
46 break bb25;
47 }
48
49 x.push(throwInput(y));
50 } catch {
51 - t43 = null;
51 + t0 = null;
52 break bb25;
53 }
54 }
55 $[0] = x;
56 - $[1] = t43;
56 + $[1] = t0;
57 } else {
58 x = $[0];
59 - t43 = $[1];
59 + t0 = $[1];
60 }
61 - if (t43 !== Symbol.for("react.early_return_sentinel")) {
62 - return t43;
61 + if (t0 !== Symbol.for("react.early_return_sentinel")) {
62 + return t0;
63 }
64 return x;
65 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md
+5 -5
@@ -43,14 +43,14 @@ function Component(props) {
43 }
44 x.push(t0);
45 } catch {
46 - let t1;
46 + let t0;
47 if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
48 - t1 = shallowCopy({});
49 - $[3] = t1;
48 + t0 = shallowCopy({});
49 + $[3] = t0;
50 } else {
51 - t1 = $[3];
51 + t0 = $[3];
52 }
53 - x.push(t1);
53 + x.push(t0);
54 }
55
56 x.push(props.value);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-annotations/todo_type-annotations-props.expect.md
+9 -9
@@ -23,22 +23,22 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react"; // @enableUseTypeAnnotations
24 function useArray(items) {
25 const $ = useMemoCache(3);
26 - let t1;
26 + let t0;
27 if ($[0] !== items) {
28 - let t0;
28 + let t1;
29 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
30 - t0 = (x) => x !== 0;
31 - $[2] = t0;
30 + t1 = (x) => x !== 0;
31 + $[2] = t1;
32 } else {
33 - t0 = $[2];
33 + t1 = $[2];
34 }
35 - t1 = items.filter(t0);
35 + t0 = items.filter(t1);
36 $[0] = items;
37 - $[1] = t1;
37 + $[1] = t0;
38 } else {
39 - t1 = $[1];
39 + t0 = $[1];
40 }
41 - return t1;
41 + return t0;
42 }
43
44 export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md
+2 -2
@@ -24,8 +24,8 @@ function Foo(props) {
24 const $ = useMemoCache(2);
25 let rest;
26 if ($[0] !== props.a) {
27 - const { unused, ...t15 } = props.a;
28 - rest = t15;
27 + const { unused, ...t0 } = props.a;
28 + rest = t0;
29 $[0] = props.a;
30 $[1] = rest;
31 } else {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md
+8 -8
@@ -20,18 +20,18 @@ function Component(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(4);
23 - let t20;
23 + let t0;
24 bb7: {
25 if (props.cond) {
26 - let t0;
26 + let t1;
27 if ($[0] !== props.a) {
28 - t0 = makeObject(props.a);
28 + t1 = makeObject(props.a);
29 $[0] = props.a;
30 - $[1] = t0;
30 + $[1] = t1;
31 } else {
32 - t0 = $[1];
32 + t1 = $[1];
33 }
34 - t20 = t0;
34 + t0 = t1;
35 break bb7;
36 }
37 let t1;
@@ -42,9 +42,9 @@ function Component(props) {
42 } else {
43 t1 = $[3];
44 }
45 - t20 = t1;
45 + t0 = t1;
46 }
47 - const x = t20;
47 + const x = t0;
48 return x;
49 }
50
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md
+21 -21
@@ -20,46 +20,46 @@ function Component(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(10);
23 - let t26;
23 let t0;
24 + let t1;
25 if ($[0] !== props.a) {
26 - t0 = makeObject(props.a);
26 + t1 = makeObject(props.a);
27 $[0] = props.a;
28 - $[1] = t0;
28 + $[1] = t1;
29 } else {
30 - t0 = $[1];
30 + t1 = $[1];
31 }
32 - const a = t0;
33 - let t1;
32 + const a = t1;
33 + let t2;
34 if ($[2] !== props.b) {
35 - t1 = makeObject(props.b);
35 + t2 = makeObject(props.b);
36 $[2] = props.b;
37 - $[3] = t1;
37 + $[3] = t2;
38 } else {
39 - t1 = $[3];
39 + t2 = $[3];
40 }
41 - const b = t1;
42 - let t2;
41 + const b = t2;
42 + let t3;
43 if ($[4] !== a || $[5] !== b) {
44 - t2 = [a, b];
44 + t3 = [a, b];
45 $[4] = a;
46 $[5] = b;
47 - $[6] = t2;
47 + $[6] = t3;
48 } else {
49 - t2 = $[6];
49 + t3 = $[6];
50 }
51 - t26 = t2;
52 - const [a_0, b_0] = t26;
53 - let t3;
51 + t0 = t3;
52 + const [a_0, b_0] = t0;
53 + let t4;
54 if ($[7] !== a_0 || $[8] !== b_0) {
55 - t3 = [a_0, b_0];
55 + t4 = [a_0, b_0];
56 $[7] = a_0;
57 $[8] = b_0;
58 - $[9] = t3;
58 + $[9] = t4;
59 } else {
60 - t3 = $[9];
60 + t4 = $[9];
61 }
62 - return t3;
62 + return t4;
63 }
64
65 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md
+8 -8
@@ -25,23 +25,23 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function component(a, b) {
27 const $ = useMemoCache(2);
28 - let t13;
28 + let t0;
29 bb6: {
30 if (a) {
31 - let t0;
31 + let t1;
32 if ($[0] !== b) {
33 - t0 = { b };
33 + t1 = { b };
34 $[0] = b;
35 - $[1] = t0;
35 + $[1] = t1;
36 } else {
37 - t0 = $[1];
37 + t1 = $[1];
38 }
39 - t13 = t0;
39 + t0 = t1;
40 break bb6;
41 }
42 - t13 = undefined;
42 + t0 = undefined;
43 }
44 - const x = t13;
44 + const x = t0;
45 return x;
46 }
47
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inverted-if.expect.md
+4 -4
@@ -27,20 +27,20 @@ export const FIXTURE_ENTRYPOINT = {
27
28 ```javascript
29 function Component(props) {
30 - let t16;
30 + let t0;
31 bb10: {
32 bb2: {
33 if (props.cond) {
34 break bb2;
35 }
36
37 - t16 = props.a;
37 + t0 = props.a;
38 break bb10;
39 }
40
41 - t16 = props.b;
41 + t0 = props.b;
42 }
43 - const x = t16;
43 + const x = t0;
44 return x;
45 }
46
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-labeled-statement-unconditional-return.expect.md
+3 -3
@@ -23,10 +23,10 @@ export const FIXTURE_ENTRYPOINT = {
23
24 ```javascript
25 function Component(props) {
26 - let t8;
26 + let t0;
27
28 - t8 = props.value;
29 - const x = t8;
28 + t0 = props.value;
29 + const x = t0;
30 return x;
31 }
32
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-logical.expect.md
+3 -3
@@ -19,9 +19,9 @@ export const FIXTURE_ENTRYPOINT = {
19
20 ```javascript
21 function Component(props) {
22 - let t16;
23 - t16 = props.a && props.b;
24 - const x = t16;
22 + let t0;
23 + t0 = props.a && props.b;
24 + const x = t0;
25 return x;
26 }
27
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-dont-preserve-memoization-guarantees.expect.md
+3 -3
@@ -56,13 +56,13 @@ function Component(props) {
56 const part = free2.part;
57
58 useHook();
59 - let t39;
59 + let t0;
60
61 const x = makeObject_Primitives();
62 x.value = props.value;
63 mutate(x, free, part);
64 - t39 = x;
65 - const object = t39;
64 + t0 = x;
65 + const object = t0;
66
67 identity(free);
68 identity(part);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-preserve-memoization-guarantees.expect.md
+3 -3
@@ -76,7 +76,7 @@ function Component(props) {
76 const part = free2.part;
77
78 useHook();
79 - let t39;
79 + let t2;
80 let x;
81 if ($[2] !== props.value) {
82 x = makeObject_Primitives();
@@ -87,8 +87,8 @@ function Component(props) {
87 } else {
88 x = $[3];
89 }
90 - t39 = x;
91 - const object = t39;
90 + t2 = x;
91 + const object = t2;
92
93 identity(free);
94 identity(part);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-dont-preserve-memoization-guarantees.expect.md
+5 -5
@@ -28,17 +28,17 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime";
28
29 function Component(props) {
30 const $ = useMemoCache(2);
31 - let t7;
31 + let t0;
32 let object;
33 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34 - t7 = makeObject_Primitives();
35 - object = t7;
34 + t0 = makeObject_Primitives();
35 + object = t0;
36 identity(object);
37 $[0] = object;
38 - $[1] = t7;
38 + $[1] = t0;
39 } else {
40 object = $[0];
41 - t7 = $[1];
41 + t0 = $[1];
42 }
43 return object;
44 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-preserve-memoization-guarantees.expect.md
+6 -6
@@ -28,16 +28,16 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime";
28
29 function Component(props) {
30 const $ = useMemoCache(1);
31 - let t7;
31 let t0;
32 + let t1;
33 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34 - t0 = makeObject_Primitives();
35 - $[0] = t0;
34 + t1 = makeObject_Primitives();
35 + $[0] = t1;
36 } else {
37 - t0 = $[0];
37 + t1 = $[0];
38 }
39 - t7 = t0;
40 - const object = t7;
39 + t0 = t1;
40 + const object = t0;
41 identity(object);
42 return object;
43 }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md
+6 -6
@@ -33,7 +33,7 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
33
34 function Component(props) {
35 const $ = useMemoCache(3);
36 - let t31;
36 + let t0;
37 bb9: {
38 let y;
39 if ($[0] !== props) {
@@ -42,21 +42,21 @@ function Component(props) {
42 y.push(props.a);
43 }
44 if (props.cond2) {
45 - t31 = y;
45 + t0 = y;
46 break bb9;
47 }
48
49 y.push(props.b);
50 $[0] = props;
51 $[1] = y;
52 - $[2] = t31;
52 + $[2] = t0;
53 } else {
54 y = $[1];
55 - t31 = $[2];
55 + t0 = $[2];
56 }
57 - t31 = y;
57 + t0 = y;
58 }
59 - const x = t31;
59 + const x = t0;
60 return x;
61 }
62
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md
+11 -11
@@ -15,26 +15,26 @@ function component(a) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function component(a) {
17 const $ = useMemoCache(4);
18 - let t9;
18 let t0;
19 + let t1;
20 if ($[0] !== a) {
21 - t0 = [a];
21 + t1 = [a];
22 $[0] = a;
23 - $[1] = t0;
23 + $[1] = t1;
24 } else {
25 - t0 = $[1];
25 + t1 = $[1];
26 }
27 - t9 = t0;
28 - const x = t9;
29 - let t1;
27 + t0 = t1;
28 + const x = t0;
29 + let t2;
30 if ($[2] !== x) {
31 - t1 = <Foo x={x} />;
31 + t2 = <Foo x={x} />;
32 $[2] = x;
33 - $[3] = t1;
33 + $[3] = t2;
34 } else {
35 - t1 = $[3];
35 + t2 = $[3];
36 }
37 - return t1;
37 + return t2;
38 }
39
40 ```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md
+4 -4
@@ -28,17 +28,17 @@ export const FIXTURE_ENTRYPOINT = {
28
29 ```javascript
30 function Component(props) {
31 - let t17;
31 + let t0;
32 bb8: switch (props.key) {
33 case "key": {
34 - t17 = props.value;
34 + t0 = props.value;
35 break bb8;
36 }
37 default: {
38 - t17 = props.defaultValue;
38 + t0 = props.defaultValue;
39 }
40 }
41 - const x = t17;
41 + const x = t0;
42 return x;
43 }
44
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-return.expect.md
+4 -4
@@ -34,12 +34,12 @@ export const FIXTURE_ENTRYPOINT = {
34
35 ```javascript
36 function Component(props) {
37 - let t21;
37 + let t0;
38 bb10: {
39 let y;
40 bb2: switch (props.switch) {
41 case "foo": {
42 - t21 = "foo";
42 + t0 = "foo";
43 break bb10;
44 }
45 case "bar": {
@@ -51,9 +51,9 @@ function Component(props) {
51 }
52 }
53
54 - t21 = y;
54 + t0 = y;
55 }
56 - const x = t21;
56 + const x = t0;
57 return x;
58 }
59
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md
+14 -14
@@ -62,33 +62,33 @@ function Component(props) {
62 return t1;
63 }
64 case 1: {
65 - let t2;
65 + let t1;
66 if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
67 - t2 = { foo: "joe" };
68 - $[3] = t2;
67 + t1 = { foo: "joe" };
68 + $[3] = t1;
69 } else {
70 - t2 = $[3];
70 + t1 = $[3];
71 }
72 - let t3;
72 + let t2;
73 if ($[4] !== onSubmit) {
74 - t3 = <OtherComponent data={t2} onSubmit={onSubmit} />;
74 + t2 = <OtherComponent data={t1} onSubmit={onSubmit} />;
75 $[4] = onSubmit;
76 - $[5] = t3;
76 + $[5] = t2;
77 } else {
78 - t3 = $[5];
78 + t2 = $[5];
79 }
80 - return t3;
80 + return t2;
81 }
82 default: {
83 logEvent("Invalid step");
84 - let t4;
84 + let t1;
85 if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
86 - t4 = <OtherComponent data={null} />;
87 - $[6] = t4;
86 + t1 = <OtherComponent data={null} />;
87 + $[6] = t1;
88 } else {
89 - t4 = $[6];
89 + t1 = $[6];
90 }
91 - return t4;
91 + return t1;
92 }
93 }
94 }