Move remaining promotion of temporaries out of codegen
I realized that codegen still had a fallback for generating identifier nodes for unnamed temporaries. This PR updates codegen to throw if it needs to generate an identifier for a temporary, and updates earlier passes to promote temporaries to named values in all the cases that were missed: * BuildHIR needs to promote temporaries for temporaries in destructuring bindings and catch clause bindings * PromoteUsedTemporaries has to promote temporaries for destructured function parameters or function params that are context variables.
Joe Savona committed
Mar 6, 2024 at 11:07 UTC
99b9da4b009b4eccda12a6546747497bcd00f5fb
76 files changed
+600
-558
compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+6
@@ -44,6 +44,7 @@ import {
44
Type,
45
makeInstructionId,
46
makeType,
47
+ promoteTemporaryToNamedIdentifier,
48
} from "./HIR";
49
import HIRBuilder, { Bindings } from "./HIRBuilder";
50
import { BuiltInArrayId } from "./ObjectShape";
@@ -1215,6 +1216,7 @@ function lowerStatement(
1216
reactive: false,
1217
loc: handlerBindingPath.node.loc ?? GeneratedSource,
1218
};
1219
+ promoteTemporaryToNamedIdentifier(place.identifier);
1220
lowerValueToTemporary(builder, {
1221
kind: "DeclareLocal",
1222
lvalue: {
@@ -3420,6 +3422,7 @@ function lowerAssignment(
3422
builder,
3423
element.node.loc ?? GeneratedSource
3424
);
3425
+ promoteTemporaryToNamedIdentifier(temp.identifier);
3426
items.push({
3427
kind: "Spread",
3428
place: { ...temp },
@@ -3447,6 +3450,7 @@ function lowerAssignment(
3450
builder,
3451
element.node.loc ?? GeneratedSource
3452
);
3453
+ promoteTemporaryToNamedIdentifier(temp.identifier);
3454
items.push({ ...temp });
3455
followups.push({ place: temp, path: element as NodePath<t.LVal> }); // TODO remove type cast
3456
}
@@ -3517,6 +3521,7 @@ function lowerAssignment(
3521
builder,
3522
property.node.loc ?? GeneratedSource
3523
);
3524
+ promoteTemporaryToNamedIdentifier(temp.identifier);
3525
properties.push({
3526
kind: "Spread",
3527
place: { ...temp },
@@ -3597,6 +3602,7 @@ function lowerAssignment(
3602
builder,
3603
element.node.loc ?? GeneratedSource
3604
);
3605
+ promoteTemporaryToNamedIdentifier(temp.identifier);
3606
properties.push({
3607
kind: "ObjectProperty",
3608
type: "property",
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+6
-1
@@ -2013,5 +2013,10 @@ function convertIdentifier(identifier: Identifier): t.Identifier {
2013
if (identifier.name !== null) {
2014
return t.identifier(identifier.name.value);
2015
}
2016
- return t.identifier(`t${identifier.id}`);
2016
+ CompilerError.invariant(false, {
2017
+ reason: `Expected temporaries to be promoted to named identifiers in an earlier pass`,
2018
+ loc: GeneratedSource,
2019
+ description: `identifier ${identifier.id} is unnamed`,
2020
+ suggestions: null,
2021
+ });
2022
}
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts
+35
-4
@@ -11,8 +11,8 @@ import {
11
Identifier,
12
IdentifierId,
13
InstructionId,
14
+ Place,
15
ReactiveFunction,
15
- ReactiveInstruction,
16
ReactiveScopeBlock,
17
ReactiveValue,
18
promoteTemporaryJsxTagToNamedIdentifier,
@@ -45,11 +45,36 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
45
}
46
}
47
}
48
- override visitInstruction(
49
- instruction: ReactiveInstruction,
48
+
49
+ override visitValue(
50
+ id: InstructionId,
51
+ value: ReactiveValue,
52
state: VisitorState
53
): void {
52
- this.traverseInstruction(instruction, state);
54
+ this.traverseValue(id, value, state);
55
+ if (value.kind === "FunctionExpression" || value.kind === "ObjectMethod") {
56
+ for (const operand of value.loweredFunc.func.params) {
57
+ const place = operand.kind === "Identifier" ? operand : operand.place;
58
+ if (place.identifier.name === null) {
59
+ promoteTemporary(place.identifier, state);
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ override visitReactiveFunctionValue(
66
+ _id: InstructionId,
67
+ _dependencies: Place[],
68
+ fn: ReactiveFunction,
69
+ state: VisitorState
70
+ ): void {
71
+ for (const operand of fn.params) {
72
+ const place = operand.kind === "Identifier" ? operand : operand.place;
73
+ if (place.identifier.name === null) {
74
+ promoteTemporary(place.identifier, state);
75
+ }
76
+ }
77
+ visitReactiveFunction(fn, this, state);
78
}
79
}
80
@@ -73,6 +98,12 @@ export function promoteUsedTemporaries(fn: ReactiveFunction): void {
98
const state: VisitorState = {
99
tags,
100
};
101
+ for (const operand of fn.params) {
102
+ const place = operand.kind === "Identifier" ? operand : operand.place;
103
+ if (place.identifier.name === null) {
104
+ promoteTemporary(place.identifier, state);
105
+ }
106
+ }
107
visitReactiveFunction(fn, new Visitor(), state);
108
}
109
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md
+17
-17
@@ -20,37 +20,37 @@ export const FIXTURE_ENTRYPOINT = {
20
21
```javascript
22
import { unstable_useMemoCache as useMemoCache } from "react";
23
-function component(t16) {
23
+function component(t0) {
24
const $ = useMemoCache(7);
25
- const [a, b] = t16;
26
- let t0;
25
+ const [a, b] = t0;
26
+ let t1;
27
if ($[0] !== a) {
28
- t0 = { a };
28
+ t1 = { a };
29
$[0] = a;
30
- $[1] = t0;
30
+ $[1] = t1;
31
} else {
32
- t0 = $[1];
32
+ t1 = $[1];
33
}
34
- const y = t0;
35
- let t1;
34
+ const y = t1;
35
+ let t2;
36
if ($[2] !== b) {
37
- t1 = { b };
37
+ t2 = { b };
38
$[2] = b;
39
- $[3] = t1;
39
+ $[3] = t2;
40
} else {
41
- t1 = $[3];
41
+ t2 = $[3];
42
}
43
- const z = t1;
44
- let t2;
43
+ const z = t2;
44
+ let t3;
45
if ($[4] !== y || $[5] !== z) {
46
- t2 = [y, z];
46
+ t3 = [y, z];
47
$[4] = y;
48
$[5] = z;
49
- $[6] = t2;
49
+ $[6] = t3;
50
} else {
51
- t2 = $[6];
51
+ t3 = $[6];
52
}
53
- return t2;
53
+ return t3;
54
}
55
56
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md
+8
-8
@@ -24,22 +24,22 @@ export const FIXTURE_ENTRYPOINT = {
24
25
```javascript
26
import { unstable_useMemoCache as useMemoCache } from "react";
27
-function App(t25) {
27
+function App(t0) {
28
const $ = useMemoCache(2);
29
- const { text, hasDeps } = t25;
29
+ const { text, hasDeps } = t0;
30
31
hasDeps ? null : [text];
32
- let t0;
32
let t1;
33
+ let t2;
34
if ($[0] !== text) {
35
- t1 = text.toUpperCase();
35
+ t2 = text.toUpperCase();
36
$[0] = text;
37
- $[1] = t1;
37
+ $[1] = t2;
38
} else {
39
- t1 = $[1];
39
+ t2 = $[1];
40
}
41
- t0 = t1;
42
- const resolvedText = t0;
41
+ t1 = t2;
42
+ const resolvedText = t1;
43
return resolvedText;
44
}
45
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md
+17
-17
@@ -20,41 +20,41 @@ function component({ mutator }) {
20
21
```javascript
22
import { unstable_useMemoCache as useMemoCache } from "react";
23
-function component(t26) {
23
+function component(t0) {
24
const $ = useMemoCache(7);
25
- const { mutator } = t26;
26
- let t0;
25
+ const { mutator } = t0;
26
+ let t1;
27
if ($[0] !== mutator) {
28
- t0 = () => {
28
+ t1 = () => {
29
mutator.poke();
30
};
31
$[0] = mutator;
32
- $[1] = t0;
32
+ $[1] = t1;
33
} else {
34
- t0 = $[1];
34
+ t1 = $[1];
35
}
36
- const poke = t0;
37
- let t1;
36
+ const poke = t1;
37
+ let t2;
38
if ($[2] !== mutator.user) {
39
- t1 = () => {
39
+ t2 = () => {
40
mutator.user.hide();
41
};
42
$[2] = mutator.user;
43
- $[3] = t1;
43
+ $[3] = t2;
44
} else {
45
- t1 = $[3];
45
+ t2 = $[3];
46
}
47
- const hide = t1;
48
- let t2;
47
+ const hide = t2;
48
+ let t3;
49
if ($[4] !== poke || $[5] !== hide) {
50
- t2 = <Foo poke={poke} hide={hide} />;
50
+ t3 = <Foo poke={poke} hide={hide} />;
51
$[4] = poke;
52
$[5] = hide;
53
- $[6] = t2;
53
+ $[6] = t3;
54
} else {
55
- t2 = $[6];
55
+ t3 = $[6];
56
}
57
- return t2;
57
+ return t3;
58
}
59
60
```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/component-declaration-basic.flow.expect.md
+7
-7
@@ -14,18 +14,18 @@ function shouldNotCompile() {}
14
15
```javascript
16
import { unstable_useMemoCache as useMemoCache } from "react";
17
-export default function Foo(t7) {
17
+export default function Foo(t0) {
18
const $ = useMemoCache(2);
19
- const { bar } = t7;
20
- let t0;
19
+ const { bar } = t0;
20
+ let t1;
21
if ($[0] !== bar) {
22
- t0 = <Bar bar={bar} />;
22
+ t1 = <Bar bar={bar} />;
23
$[0] = bar;
24
- $[1] = t0;
24
+ $[1] = t1;
25
} else {
26
- t0 = $[1];
26
+ t1 = $[1];
27
}
28
- return t0;
28
+ return t1;
29
}
30
31
function shouldNotCompile() {}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/context-variable-reactive-explicit-control-flow.expect.md
+2
-2
@@ -29,9 +29,9 @@ export const FIXTURE_ENTRYPOINT = {
29
import { unstable_useMemoCache as useMemoCache } from "react";
30
import { invoke } from "shared-runtime";
31
32
-function Component(t21) {
32
+function Component(t0) {
33
const $ = useMemoCache(2);
34
- const { shouldReassign } = t21;
34
+ const { shouldReassign } = t0;
35
let x;
36
if ($[0] !== shouldReassign) {
37
x = null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/context-variable-reactive-implicit-control-flow.expect.md
+2
-2
@@ -33,9 +33,9 @@ import { conditionalInvoke } from "shared-runtime";
33
// same as context-variable-reactive-explicit-control-flow.js, but make
34
// the control flow implicit
35
36
-function Component(t20) {
36
+function Component(t0) {
37
const $ = useMemoCache(2);
38
- const { shouldReassign } = t20;
38
+ const { shouldReassign } = t0;
39
let x;
40
if ($[0] !== shouldReassign) {
41
x = null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/context-variable-reassigned-objectmethod.expect.md
+2
-2
@@ -30,9 +30,9 @@ export const FIXTURE_ENTRYPOINT = {
30
import { unstable_useMemoCache as useMemoCache } from "react";
31
import { invoke } from "shared-runtime";
32
33
-function Component(t24) {
33
+function Component(t0) {
34
const $ = useMemoCache(2);
35
- const { cond } = t24;
35
+ const { cond } = t0;
36
let x;
37
if ($[0] !== cond) {
38
x = 2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/context-variable-reassigned-reactive-capture.expect.md
+2
-2
@@ -27,9 +27,9 @@ export const FIXTURE_ENTRYPOINT = {
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { invoke } from "shared-runtime";
29
30
-function Component(t20) {
30
+function Component(t0) {
31
const $ = useMemoCache(2);
32
- const { value } = t20;
32
+ const { value } = t0;
33
let x;
34
if ($[0] !== value) {
35
x = null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/context-variable-reassigned-two-lambdas.expect.md
+2
-2
@@ -35,9 +35,9 @@ export const FIXTURE_ENTRYPOINT = {
35
import { unstable_useMemoCache as useMemoCache } from "react";
36
import { conditionalInvoke } from "shared-runtime";
37
38
-function Component(t32) {
38
+function Component(t0) {
39
const $ = useMemoCache(3);
40
- const { doReassign1, doReassign2 } = t32;
40
+ const { doReassign1, doReassign2 } = t0;
41
let x;
42
if ($[0] !== doReassign1 || $[1] !== doReassign2) {
43
x = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-assignment-to-context-var.expect.md
+2
-2
@@ -31,8 +31,8 @@ function Component(props) {
31
const $ = useMemoCache(4);
32
let x;
33
if ($[0] !== props.value) {
34
- const [t31] = props.value;
35
- x = t31;
34
+ const [t0] = props.value;
35
+ x = t0;
36
const foo = () => {
37
x = identity(props.value[0]);
38
};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-assignment-to-context-var.expect.md
+2
-2
@@ -31,8 +31,8 @@ function Component(props) {
31
const $ = useMemoCache(4);
32
let x;
33
if ($[0] !== props) {
34
- const { x: t27 } = props;
35
- x = t27;
34
+ const { x: t0 } = props;
35
+ x = t0;
36
const foo = () => {
37
x = identity(props.x);
38
};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-param-string-literal-key-invalid-identifier.expect.md
+2
-2
@@ -17,8 +17,8 @@ export const FIXTURE_ENTRYPOINT = {
17
## Code
18
19
```javascript
20
-function foo(t5) {
21
- const { "data-foo-bar": dataTestID } = t5;
20
+function foo(t0) {
21
+ const { "data-foo-bar": dataTestID } = t0;
22
return dataTestID;
23
}
24
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-param-string-literal-key.expect.md
+2
-2
@@ -17,8 +17,8 @@ export const FIXTURE_ENTRYPOINT = {
17
## Code
18
19
```javascript
20
-function foo(t5) {
21
- const { data: dataTestID } = t5;
20
+function foo(t0) {
21
+ const { data: dataTestID } = t0;
22
return dataTestID;
23
}
24
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-array-param-default.expect.md
+3
-3
@@ -17,9 +17,9 @@ export const FIXTURE_ENTRYPOINT = {
17
## Code
18
19
```javascript
20
-function Component(t13) {
21
- const [t14] = t13;
22
- const a = t14 === undefined ? 2 : t14;
20
+function Component(t0) {
21
+ const [t1] = t0;
22
+ const a = t1 === undefined ? 2 : t1;
23
return a;
24
}
25
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md
+15
-15
@@ -39,28 +39,28 @@ function foo(a, b, c) {
39
let g;
40
let n;
41
let o;
42
- const [t49, t50] = a;
43
- d = t49;
44
- const [t54] = t50;
45
- const { e: t56 } = t54;
46
- ({ f: g } = t56);
47
- const { l: t61, o: t62 } = b;
48
- const { m: t64 } = t61;
49
- const [t66] = t64;
50
- [n] = t66;
51
- o = t62;
52
- let t0;
42
+ const [t0, t1] = a;
43
+ d = t0;
44
+ const [t2] = t1;
45
+ const { e: t3 } = t2;
46
+ ({ f: g } = t3);
47
+ const { l: t4, o: t5 } = b;
48
+ const { m: t6 } = t4;
49
+ const [t7] = t6;
50
+ [n] = t7;
51
+ o = t5;
52
+ let t8;
53
if ($[0] !== d || $[1] !== g || $[2] !== n || $[3] !== o) {
54
- t0 = { d, g, n, o };
54
+ t8 = { d, g, n, o };
55
$[0] = d;
56
$[1] = g;
57
$[2] = n;
58
$[3] = o;
59
- $[4] = t0;
59
+ $[4] = t8;
60
} else {
61
- t0 = $[4];
61
+ t8 = $[4];
62
}
63
- return t0;
63
+ return t8;
64
}
65
66
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-default-at-array-hole.expect.md
+2
-2
@@ -19,8 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19
20
```javascript
21
function Component(props) {
22
- const [t18] = props.value;
23
- const x = t18 === undefined ? 42 : t18;
22
+ const [t0] = props.value;
23
+ const x = t0 === undefined ? 42 : t0;
24
return x;
25
}
26
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-default-at-explicit-null.expect.md
+2
-2
@@ -19,8 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19
20
```javascript
21
function Component(props) {
22
- const [t18] = props.value;
23
- const x = t18 === undefined ? 42 : t18;
22
+ const [t0] = props.value;
23
+ const x = t0 === undefined ? 42 : t0;
24
return x;
25
}
26
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-default-at-explicit-undefined.expect.md
+2
-2
@@ -19,8 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19
20
```javascript
21
function Component(props) {
22
- const [t18] = props.value;
23
- const x = t18 === undefined ? 42 : t18;
22
+ const [t0] = props.value;
23
+ const x = t0 === undefined ? 42 : t0;
24
return x;
25
}
26
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-default-past-end-of-array.expect.md
+2
-2
@@ -19,8 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19
20
```javascript
21
function Component(props) {
22
- const [t18] = props.value;
23
- const x = t18 === undefined ? 42 : t18;
22
+ const [t0] = props.value;
23
+ const x = t0 === undefined ? 42 : t0;
24
return x;
25
}
26
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-object-param-default.expect.md
+3
-3
@@ -17,9 +17,9 @@ export const FIXTURE_ENTRYPOINT = {
17
## Code
18
19
```javascript
20
-function Component(t13) {
21
- const { a: t14 } = t13;
22
- const a = t14 === undefined ? 2 : t14;
20
+function Component(t0) {
21
+ const { a: t1 } = t0;
22
+ const a = t1 === undefined ? 2 : t1;
23
return a;
24
}
25
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-same-property-identifier-names.expect.md
+12
-12
@@ -29,27 +29,27 @@ import { identity } from "shared-runtime";
29
30
function Component(props) {
31
const $ = useMemoCache(5);
32
- const { x: t18, sameName: renamed } = props;
33
- const { destructured } = t18;
34
- let t0;
32
+ const { x: t0, sameName: renamed } = props;
33
+ const { destructured } = t0;
34
+ let t1;
35
if ($[0] !== destructured) {
36
- t0 = identity(destructured);
36
+ t1 = identity(destructured);
37
$[0] = destructured;
38
- $[1] = t0;
38
+ $[1] = t1;
39
} else {
40
- t0 = $[1];
40
+ t1 = $[1];
41
}
42
- const sameName = t0;
43
- let t1;
42
+ const sameName = t1;
43
+ let t2;
44
if ($[2] !== sameName || $[3] !== renamed) {
45
- t1 = [sameName, renamed];
45
+ t2 = [sameName, renamed];
46
$[2] = sameName;
47
$[3] = renamed;
48
- $[4] = t1;
48
+ $[4] = t2;
49
} else {
50
- t1 = $[4];
50
+ t2 = $[4];
51
}
52
- return t1;
52
+ return t2;
53
}
54
55
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-with-conditional-as-default-value.expect.md
+2
-2
@@ -18,8 +18,8 @@ export const FIXTURE_ENTRYPOINT = {
18
19
```javascript
20
function Component(props) {
21
- const [t23] = props.y;
22
- const x = t23 === undefined ? (true ? 1 : 0) : t23;
21
+ const [t0] = props.y;
22
+ const x = t0 === undefined ? (true ? 1 : 0) : t0;
23
return x;
24
}
25
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring.expect.md
+14
-14
@@ -63,21 +63,21 @@ function foo(a, b, c) {
63
g = $[6];
64
}
65
const { f } = t2;
66
- const { l: t51, p } = b;
67
- const { m: t3 } = t51;
68
- let t4;
66
+ const { l: t3, p } = b;
67
+ const { m: t4 } = t3;
68
+ let t5;
69
let o;
70
- if ($[7] !== t3) {
71
- [t4, ...o] = t3;
72
- $[7] = t3;
73
- $[8] = t4;
70
+ if ($[7] !== t4) {
71
+ [t5, ...o] = t4;
72
+ $[7] = t4;
73
+ $[8] = t5;
74
$[9] = o;
75
} else {
76
- t4 = $[8];
76
+ t5 = $[8];
77
o = $[9];
78
}
79
- const [n] = t4;
80
- let t5;
79
+ const [n] = t5;
80
+ let t6;
81
if (
82
$[10] !== d ||
83
$[11] !== f ||
@@ -87,7 +87,7 @@ function foo(a, b, c) {
87
$[15] !== o ||
88
$[16] !== p
89
) {
90
- t5 = [d, f, g, h, n, o, p];
90
+ t6 = [d, f, g, h, n, o, p];
91
$[10] = d;
92
$[11] = f;
93
$[12] = g;
@@ -95,11 +95,11 @@ function foo(a, b, c) {
95
$[14] = n;
96
$[15] = o;
97
$[16] = p;
98
- $[17] = t5;
98
+ $[17] = t6;
99
} else {
100
- t5 = $[17];
100
+ t6 = $[17];
101
}
102
- return t5;
102
+ return t6;
103
}
104
105
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbt-no-whitespace-btw-text-and-param.expect.md
+7
-7
@@ -27,22 +27,22 @@ import { unstable_useMemoCache as useMemoCache } from "react";
27
import fbt from "fbt";
28
29
const _ = fbt;
30
-function Component(t12) {
30
+function Component(t0) {
31
const $ = useMemoCache(2);
32
- const { value } = t12;
33
- let t0;
32
+ const { value } = t0;
33
+ let t1;
34
if ($[0] !== value) {
35
- t0 = fbt._(
35
+ t1 = fbt._(
36
"Before text{paramName}After text",
37
[fbt._param("paramName", value)],
38
{ hk: "aKEGX" }
39
);
40
$[0] = value;
41
- $[1] = t0;
41
+ $[1] = t1;
42
} else {
43
- t0 = $[1];
43
+ t1 = $[1];
44
}
45
- return t0;
45
+ return t1;
46
}
47
48
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbt-preserve-whitespace.expect.md
+7
-7
@@ -28,12 +28,12 @@ import { unstable_useMemoCache as useMemoCache } from "react";
28
import fbt from "fbt";
29
30
const _ = fbt;
31
-function Component(t12) {
31
+function Component(t0) {
32
const $ = useMemoCache(2);
33
- const { value } = t12;
34
- let t0;
33
+ const { value } = t0;
34
+ let t1;
35
if ($[0] !== value) {
36
- t0 = fbt._(
36
+ t1 = fbt._(
37
"Before text {paramName}",
38
[
39
fbt._param(
@@ -45,11 +45,11 @@ function Component(t12) {
45
{ hk: "3z5SVE" }
46
);
47
$[0] = value;
48
- $[1] = t0;
48
+ $[1] = t1;
49
} else {
50
- t0 = $[1];
50
+ t1 = $[1];
51
}
52
- return t0;
52
+ return t1;
53
}
54
55
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbt-single-space-btw-param-and-text.expect.md
+7
-7
@@ -27,22 +27,22 @@ import { unstable_useMemoCache as useMemoCache } from "react";
27
import fbt from "fbt";
28
29
const _ = fbt;
30
-function Component(t12) {
30
+function Component(t0) {
31
const $ = useMemoCache(2);
32
- const { value } = t12;
33
- let t0;
32
+ const { value } = t0;
33
+ let t1;
34
if ($[0] !== value) {
35
- t0 = fbt._(
35
+ t1 = fbt._(
36
"Before text {paramName} after text",
37
[fbt._param("paramName", value)],
38
{ hk: "26pxNm" }
39
);
40
$[0] = value;
41
- $[1] = t0;
41
+ $[1] = t1;
42
} else {
43
- t0 = $[1];
43
+ t1 = $[1];
44
}
45
- return t0;
45
+ return t1;
46
}
47
48
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbt-whitespace-around-param-value.expect.md
+7
-7
@@ -27,22 +27,22 @@ import { unstable_useMemoCache as useMemoCache } from "react";
27
import fbt from "fbt";
28
29
const _ = fbt;
30
-function Component(t14) {
30
+function Component(t0) {
31
const $ = useMemoCache(2);
32
- const { value } = t14;
33
- let t0;
32
+ const { value } = t0;
33
+ let t1;
34
if ($[0] !== value) {
35
- t0 = fbt._(
35
+ t1 = fbt._(
36
"Before text {paramName} after text",
37
[fbt._param("paramName", value)],
38
{ hk: "26pxNm" }
39
);
40
$[0] = value;
41
- $[1] = t0;
41
+ $[1] = t1;
42
} else {
43
- t0 = $[1];
43
+ t1 = $[1];
44
}
45
- return t0;
45
+ return t1;
46
}
47
48
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbt-whitespace-within-text.expect.md
+7
-7
@@ -29,22 +29,22 @@ import { unstable_useMemoCache as useMemoCache } from "react";
29
import fbt from "fbt";
30
31
const _ = fbt;
32
-function Component(t12) {
32
+function Component(t0) {
33
const $ = useMemoCache(2);
34
- const { value } = t12;
35
- let t0;
34
+ const { value } = t0;
35
+ let t1;
36
if ($[0] !== value) {
37
- t0 = fbt._(
37
+ t1 = fbt._(
38
"Before text {paramName} after text more text and more and more and more and more and more and more and more and more and blah blah blah blah",
39
[fbt._param("paramName", value)],
40
{ hk: "24ZPpO" }
41
);
42
$[0] = value;
43
- $[1] = t0;
43
+ $[1] = t1;
44
} else {
45
- t0 = $[1];
45
+ t1 = $[1];
46
}
47
- return t0;
47
+ return t1;
48
}
49
50
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/fbtparam-with-jsx-element-content.expect.md
+7
-7
@@ -28,12 +28,12 @@ function Component({ name, data, icon }) {
28
import { unstable_useMemoCache as useMemoCache } from "react";
29
import fbt from "fbt";
30
31
-function Component(t33) {
31
+function Component(t0) {
32
const $ = useMemoCache(4);
33
- const { name, data, icon } = t33;
34
- let t0;
33
+ const { name, data, icon } = t0;
34
+ let t1;
35
if ($[0] !== name || $[1] !== icon || $[2] !== data) {
36
- t0 = (
36
+ t1 = (
37
<Text type="body4">
38
{fbt._(
39
"{item author}{icon}{=m2}",
@@ -64,11 +64,11 @@ function Component(t33) {
64
$[0] = name;
65
$[1] = icon;
66
$[2] = data;
67
- $[3] = t0;
67
+ $[3] = t1;
68
} else {
69
- t0 = $[3];
69
+ t1 = $[3];
70
}
71
- return t0;
71
+ return t1;
72
}
73
74
```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md
+15
-15
@@ -53,49 +53,49 @@ import {
53
} from "shared-runtime";
54
55
const MyContext = createContext("my context value");
56
-function Component(t47) {
56
+function Component(t0) {
57
const $ = useMemoCache(4);
58
try {
59
$dispatcherGuard(0);
60
- const { value } = t47;
60
+ const { value } = t0;
61
print(identity(CONST_STRING0));
62
- let t0;
62
+ let t1;
63
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
64
- t0 = getNumber();
65
- $[0] = t0;
64
+ t1 = getNumber();
65
+ $[0] = t1;
66
} else {
67
- t0 = $[0];
67
+ t1 = $[0];
68
}
69
const [state, setState] = (function () {
70
try {
71
$dispatcherGuard(2);
72
- return useState(t0);
72
+ return useState(t1);
73
} finally {
74
$dispatcherGuard(3);
75
}
76
})();
77
print(value, state);
78
- let t1;
78
let t2;
79
+ let t3;
80
if ($[1] !== state) {
81
- t1 = () => {
81
+ t2 = () => {
82
if (state === 4) {
83
setState(5);
84
}
85
};
86
87
- t2 = [state];
87
+ t3 = [state];
88
$[1] = state;
89
- $[2] = t1;
90
- $[3] = t2;
89
+ $[2] = t2;
90
+ $[3] = t3;
91
} else {
92
- t1 = $[2];
93
- t2 = $[3];
92
+ t2 = $[2];
93
+ t3 = $[3];
94
}
95
(function () {
96
try {
97
$dispatcherGuard(2);
98
- return useEffect(t1, t2);
98
+ return useEffect(t2, t3);
99
} finally {
100
$dispatcherGuard(3);
101
}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md
+14
-14
@@ -18,28 +18,28 @@ export const FIXTURE_ENTRYPOINT = {
18
19
```javascript
20
import { unstable_useMemoCache as useMemoCache } from "react";
21
-function Component(t23, t0) {
21
+function Component(t0, t1) {
22
const $ = useMemoCache(5);
23
- const x = t23 === undefined ? "default" : t23;
24
- let t1;
25
- if ($[0] !== t0) {
26
- t1 = t0 === undefined ? [{}] : t0;
27
- $[0] = t0;
28
- $[1] = t1;
23
+ const x = t0 === undefined ? "default" : t0;
24
+ let t2;
25
+ if ($[0] !== t1) {
26
+ t2 = t1 === undefined ? [{}] : t1;
27
+ $[0] = t1;
28
+ $[1] = t2;
29
} else {
30
- t1 = $[1];
30
+ t2 = $[1];
31
}
32
- const y = t1;
33
- let t2;
32
+ const y = t2;
33
+ let t3;
34
if ($[2] !== x || $[3] !== y) {
35
- t2 = [x, y];
35
+ t3 = [x, y];
36
$[2] = x;
37
$[3] = y;
38
- $[4] = t2;
38
+ $[4] = t3;
39
} else {
40
- t2 = $[4];
40
+ t3 = $[4];
41
}
42
- return t2;
42
+ return t3;
43
}
44
45
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hoisting-recursive-call-within-lambda.expect.md
+11
-11
@@ -26,11 +26,11 @@ export const FIXTURE_ENTRYPOINT = {
26
27
```javascript
28
import { unstable_useMemoCache as useMemoCache } from "react";
29
-function Foo(t32) {
29
+function Foo(t0) {
30
const $ = useMemoCache(2);
31
- let t0;
31
+ let t1;
32
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
33
- t0 = (val) => {
33
+ t1 = (val) => {
34
const fact = (x) => {
35
if (x <= 0) {
36
return 1;
@@ -39,19 +39,19 @@ function Foo(t32) {
39
};
40
return fact(val);
41
};
42
- $[0] = t0;
42
+ $[0] = t1;
43
} else {
44
- t0 = $[0];
44
+ t1 = $[0];
45
}
46
- const outer = t0;
47
- let t1;
46
+ const outer = t1;
47
+ let t2;
48
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
49
- t1 = outer(3);
50
- $[1] = t1;
49
+ t2 = outer(3);
50
+ $[1] = t2;
51
} else {
52
- t1 = $[1];
52
+ t2 = $[1];
53
}
54
- return t1;
54
+ return t2;
55
}
56
57
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hoisting-recursive-call.expect.md
+7
-7
@@ -25,10 +25,10 @@ export const FIXTURE_ENTRYPOINT = {
25
26
```javascript
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
-function Foo(t25) {
28
+function Foo(t0) {
29
const $ = useMemoCache(2);
30
- const { value } = t25;
31
- let t0;
30
+ const { value } = t0;
31
+ let t1;
32
if ($[0] !== value) {
33
const factorial = (x) => {
34
if (x <= 1) {
@@ -38,13 +38,13 @@ function Foo(t25) {
38
}
39
};
40
41
- t0 = factorial(value);
41
+ t1 = factorial(value);
42
$[0] = value;
43
- $[1] = t0;
43
+ $[1] = t1;
44
} else {
45
- t0 = $[1];
45
+ t1 = $[1];
46
}
47
- return t0;
47
+ return t1;
48
}
49
50
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hoisting-within-lambda.expect.md
+11
-11
@@ -24,29 +24,29 @@ export const FIXTURE_ENTRYPOINT = {
24
25
```javascript
26
import { unstable_useMemoCache as useMemoCache } from "react";
27
-function Component(t22) {
27
+function Component(t0) {
28
const $ = useMemoCache(2);
29
- let t0;
29
+ let t1;
30
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31
- t0 = () => {
31
+ t1 = () => {
32
const inner = () => x;
33
34
const x = 3;
35
return inner();
36
};
37
- $[0] = t0;
37
+ $[0] = t1;
38
} else {
39
- t0 = $[0];
39
+ t1 = $[0];
40
}
41
- const outer = t0;
42
- let t1;
41
+ const outer = t1;
42
+ let t2;
43
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
44
- t1 = <div>{outer()}</div>;
45
- $[1] = t1;
44
+ t2 = <div>{outer()}</div>;
45
+ $[1] = t2;
46
} else {
47
- t1 = $[1];
47
+ t2 = $[1];
48
}
49
- return t1;
49
+ return t2;
50
}
51
52
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/infer-functions-component-with-ref-arg.expect.md
+6
-6
@@ -20,17 +20,17 @@ export const FIXTURE_ENTRYPOINT = {
20
```javascript
21
import { unstable_useMemoCache as useMemoCache } from "react"; // @compilationMode(infer)
22
23
-function Foo(t6, ref) {
23
+function Foo(t0, ref) {
24
const $ = useMemoCache(2);
25
- let t0;
25
+ let t1;
26
if ($[0] !== ref) {
27
- t0 = <div ref={ref} />;
27
+ t1 = <div ref={ref} />;
28
$[0] = ref;
29
- $[1] = t0;
29
+ $[1] = t1;
30
} else {
31
- t0 = $[1];
31
+ t1 = $[1];
32
}
33
- return t0;
33
+ return t1;
34
}
35
36
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-attribute-with-jsx-element-value.expect.md
+23
-23
@@ -43,12 +43,12 @@ export const FIXTURE_ENTRYPOINT = {
43
44
```javascript
45
import { unstable_useMemoCache as useMemoCache } from "react";
46
-function Component(t27) {
46
+function Component(t0) {
47
const $ = useMemoCache(2);
48
- const { items } = t27;
49
- let t0;
48
+ const { items } = t0;
49
+ let t1;
50
if ($[0] !== items) {
51
- t0 =
51
+ t1 =
52
items.length > 0 ? (
53
<Foo
54
value={
@@ -61,44 +61,44 @@ function Component(t27) {
61
/>
62
) : null;
63
$[0] = items;
64
- $[1] = t0;
64
+ $[1] = t1;
65
} else {
66
- t0 = $[1];
66
+ t1 = $[1];
67
}
68
- return t0;
68
+ return t1;
69
}
70
71
-function Foo(t5) {
72
- const { value } = t5;
71
+function Foo(t0) {
72
+ const { value } = t0;
73
return value;
74
}
75
76
-function Bar(t6) {
76
+function Bar(t0) {
77
const $ = useMemoCache(2);
78
- const { children } = t6;
79
- let t0;
78
+ const { children } = t0;
79
+ let t1;
80
if ($[0] !== children) {
81
- t0 = <div>{children}</div>;
81
+ t1 = <div>{children}</div>;
82
$[0] = children;
83
- $[1] = t0;
83
+ $[1] = t1;
84
} else {
85
- t0 = $[1];
85
+ t1 = $[1];
86
}
87
- return t0;
87
+ return t1;
88
}
89
90
-function Item(t7) {
90
+function Item(t0) {
91
const $ = useMemoCache(2);
92
- const { item } = t7;
93
- let t0;
92
+ const { item } = t0;
93
+ let t1;
94
if ($[0] !== item.name) {
95
- t0 = <div>{item.name}</div>;
95
+ t1 = <div>{item.name}</div>;
96
$[0] = item.name;
97
- $[1] = t0;
97
+ $[1] = t1;
98
} else {
99
- t0 = $[1];
99
+ t1 = $[1];
100
}
101
- return t0;
101
+ return t1;
102
}
103
104
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-attribute-with-jsx-fragment-value.flow.expect.md
+14
-14
@@ -34,12 +34,12 @@ export const FIXTURE_ENTRYPOINT = {
34
import { unstable_useMemoCache as useMemoCache } from "react";
35
import { Stringify } from "shared-runtime";
36
37
-function Component(t26) {
37
+function Component(t0) {
38
const $ = useMemoCache(2);
39
- const { items } = t26;
40
- let t0;
39
+ const { items } = t0;
40
+ let t1;
41
if ($[0] !== items) {
42
- t0 =
42
+ t1 =
43
items.length > 0 ? (
44
<Foo
45
value={
@@ -52,25 +52,25 @@ function Component(t26) {
52
/>
53
) : null;
54
$[0] = items;
55
- $[1] = t0;
55
+ $[1] = t1;
56
} else {
57
- t0 = $[1];
57
+ t1 = $[1];
58
}
59
- return t0;
59
+ return t1;
60
}
61
62
-function Foo(t6) {
62
+function Foo(t0) {
63
const $ = useMemoCache(2);
64
- const { value } = t6;
65
- let t0;
64
+ const { value } = t0;
65
+ let t1;
66
if ($[0] !== value) {
67
- t0 = <div>{value}</div>;
67
+ t1 = <div>{value}</div>;
68
$[0] = value;
69
- $[1] = t0;
69
+ $[1] = t1;
70
} else {
71
- t0 = $[1];
71
+ t1 = $[1];
72
}
73
- return t0;
73
+ return t1;
74
}
75
76
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.expect.md
+7
-7
@@ -24,19 +24,19 @@ export const FIXTURE_ENTRYPOINT = {
24
```javascript
25
import { unstable_useMemoCache as useMemoCache } from "react";
26
import * as SharedRuntime from "shared-runtime";
27
-function useFoo(t12) {
27
+function useFoo(t0) {
28
const $ = useMemoCache(1);
29
- const { cond } = t12;
29
+ const { cond } = t0;
30
const MyLocal = SharedRuntime;
31
if (cond) {
32
- let t0;
32
+ let t1;
33
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34
- t0 = <MyLocal.Text value={4} />;
35
- $[0] = t0;
34
+ t1 = <MyLocal.Text value={4} />;
35
+ $[0] = t1;
36
} else {
37
- t0 = $[0];
37
+ t1 = $[0];
38
}
39
- return t0;
39
+ return t1;
40
} else {
41
return null;
42
}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-reactive-local-variable-member-expr.expect.md
+7
-7
@@ -26,20 +26,20 @@ export const FIXTURE_ENTRYPOINT = {
26
import { unstable_useMemoCache as useMemoCache } from "react";
27
import * as sharedRuntime from "shared-runtime";
28
29
-function Component(t13) {
29
+function Component(t0) {
30
const $ = useMemoCache(2);
31
- const { something } = t13;
31
+ const { something } = t0;
32
33
const Foo = something.StaticText1;
34
- let t0;
34
+ let t1;
35
if ($[0] !== Foo) {
36
- t0 = () => <Foo />;
36
+ t1 = () => <Foo />;
37
$[0] = Foo;
38
- $[1] = t0;
38
+ $[1] = t1;
39
} else {
40
- t0 = $[1];
40
+ t1 = $[1];
41
}
42
- return t0;
42
+ return t1;
43
}
44
45
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/maybe-mutate-object-in-callback.expect.md
+2
-2
@@ -62,8 +62,8 @@ function Component(props) {
62
return t2;
63
}
64
65
-function Foo(t5) {
66
- const { children } = t5;
65
+function Foo(t0) {
66
+ const { children } = t0;
67
return children;
68
}
69
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md
+2
-2
@@ -28,8 +28,8 @@ function Foo() {
28
let t0;
29
let t1;
30
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31
- t1 = function a(t28) {
32
- const x_0 = t28 === undefined ? () => {} : t28;
31
+ t1 = function a(t0) {
32
+ const x_0 = t0 === undefined ? () => {} : t0;
33
return x_0;
34
};
35
$[0] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-literal-method-call-in-ternary-test.expect.md
+2
-2
@@ -36,8 +36,8 @@ import {
36
CONST_STRING1,
37
} from "shared-runtime";
38
39
-function useHook(t18) {
40
- const { value } = t18;
39
+function useHook(t0) {
40
+ const { value } = t0;
41
return {
42
getValue() {
43
return identity(value);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-literal-method-derived-in-ternary-consequent.expect.md
+7
-7
@@ -27,12 +27,12 @@ export const FIXTURE_ENTRYPOINT = {
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { identity, createHookWrapper } from "shared-runtime";
29
30
-function useHook(t17) {
30
+function useHook(t0) {
31
const $ = useMemoCache(3);
32
- const { isCond, value } = t17;
33
- let t0;
32
+ const { isCond, value } = t0;
33
+ let t1;
34
if ($[0] !== isCond || $[1] !== value) {
35
- t0 = isCond
35
+ t1 = isCond
36
? identity({
37
getValue() {
38
return value;
@@ -41,11 +41,11 @@ function useHook(t17) {
41
: 42;
42
$[0] = isCond;
43
$[1] = value;
44
- $[2] = t0;
44
+ $[2] = t1;
45
} else {
46
- t0 = $[2];
46
+ t1 = $[2];
47
}
48
- return t0;
48
+ return t1;
49
}
50
51
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-literal-method-in-ternary-consequent.expect.md
+7
-7
@@ -27,12 +27,12 @@ export const FIXTURE_ENTRYPOINT = {
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { createHookWrapper } from "shared-runtime";
29
30
-function useHook(t15) {
30
+function useHook(t0) {
31
const $ = useMemoCache(3);
32
- const { isCond, value } = t15;
33
- let t0;
32
+ const { isCond, value } = t0;
33
+ let t1;
34
if ($[0] !== isCond || $[1] !== value) {
35
- t0 = isCond
35
+ t1 = isCond
36
? {
37
getValue() {
38
return value;
@@ -41,11 +41,11 @@ function useHook(t15) {
41
: 42;
42
$[0] = isCond;
43
$[1] = value;
44
- $[2] = t0;
44
+ $[2] = t1;
45
} else {
46
- t0 = $[2];
46
+ t1 = $[2];
47
}
48
- return t0;
48
+ return t1;
49
}
50
51
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-literal-method-in-ternary-test.expect.md
+2
-2
@@ -34,8 +34,8 @@ import {
34
CONST_STRING1,
35
} from "shared-runtime";
36
37
-function useHook(t16) {
38
- const { value } = t16;
37
+function useHook(t0) {
38
+ const { value } = t0;
39
return {
40
getValue() {
41
return identity(value);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-method-shorthand-aliased-mutate-after.expect.md
+2
-2
@@ -26,9 +26,9 @@ export const FIXTURE_ENTRYPOINT = {
26
```javascript
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { createHookWrapper, mutate, mutateAndReturn } from "shared-runtime";
29
-function useHook(t21) {
29
+function useHook(t0) {
30
const $ = useMemoCache(2);
31
- const { value } = t21;
31
+ const { value } = t0;
32
let obj;
33
if ($[0] !== value) {
34
const x = mutateAndReturn({ value });
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-method-shorthand-derived-value.expect.md
+12
-12
@@ -25,31 +25,31 @@ export const FIXTURE_ENTRYPOINT = {
25
```javascript
26
import { unstable_useMemoCache as useMemoCache } from "react";
27
import { createHookWrapper, mutateAndReturn } from "shared-runtime";
28
-function useHook(t18) {
28
+function useHook(t0) {
29
const $ = useMemoCache(4);
30
- const { value } = t18;
31
- let t0;
30
+ const { value } = t0;
31
+ let t1;
32
if ($[0] !== value) {
33
- t0 = mutateAndReturn({ value });
33
+ t1 = mutateAndReturn({ value });
34
$[0] = value;
35
- $[1] = t0;
35
+ $[1] = t1;
36
} else {
37
- t0 = $[1];
37
+ t1 = $[1];
38
}
39
- const x = t0;
40
- let t1;
39
+ const x = t1;
40
+ let t2;
41
if ($[2] !== x) {
42
- t1 = {
42
+ t2 = {
43
getValue() {
44
return x;
45
},
46
};
47
$[2] = x;
48
- $[3] = t1;
48
+ $[3] = t2;
49
} else {
50
- t1 = $[3];
50
+ t2 = $[3];
51
}
52
- const obj = t1;
52
+ const obj = t2;
53
return obj;
54
}
55
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-method-shorthand-mutated-after.expect.md
+2
-2
@@ -26,9 +26,9 @@ export const FIXTURE_ENTRYPOINT = {
26
```javascript
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { createHookWrapper, mutate, mutateAndReturn } from "shared-runtime";
29
-function useHook(t21) {
29
+function useHook(t0) {
30
const $ = useMemoCache(2);
31
- const { value } = t21;
31
+ const { value } = t0;
32
let obj;
33
if ($[0] !== value) {
34
const x = mutateAndReturn({ value });
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md
+17
-17
@@ -20,37 +20,37 @@ export const FIXTURE_ENTRYPOINT = {
20
21
```javascript
22
import { unstable_useMemoCache as useMemoCache } from "react";
23
-function component(t16) {
23
+function component(t0) {
24
const $ = useMemoCache(7);
25
- const { a, b } = t16;
26
- let t0;
25
+ const { a, b } = t0;
26
+ let t1;
27
if ($[0] !== a) {
28
- t0 = { a };
28
+ t1 = { a };
29
$[0] = a;
30
- $[1] = t0;
30
+ $[1] = t1;
31
} else {
32
- t0 = $[1];
32
+ t1 = $[1];
33
}
34
- const y = t0;
35
- let t1;
34
+ const y = t1;
35
+ let t2;
36
if ($[2] !== b) {
37
- t1 = { b };
37
+ t2 = { b };
38
$[2] = b;
39
- $[3] = t1;
39
+ $[3] = t2;
40
} else {
41
- t1 = $[3];
41
+ t2 = $[3];
42
}
43
- const z = t1;
44
- let t2;
43
+ const z = t2;
44
+ let t3;
45
if ($[4] !== y || $[5] !== z) {
46
- t2 = { y, z };
46
+ t3 = { y, z };
47
$[4] = y;
48
$[5] = z;
49
- $[6] = t2;
49
+ $[6] = t3;
50
} else {
51
- t2 = $[6];
51
+ t3 = $[6];
52
}
53
- return t2;
53
+ return t3;
54
}
55
56
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-1.expect.md
+14
-14
@@ -26,34 +26,34 @@ export const FIXTURE_ENTRYPOINT = {
26
```javascript
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { createHookWrapper } from "shared-runtime";
29
-function useHook(t16) {
29
+function useHook(t0) {
30
const $ = useMemoCache(5);
31
- const { a, b } = t16;
32
- let t0;
31
+ const { a, b } = t0;
32
+ let t1;
33
if ($[0] !== a) {
34
- t0 = function () {
34
+ t1 = function () {
35
return [a];
36
};
37
$[0] = a;
38
- $[1] = t0;
38
+ $[1] = t1;
39
} else {
40
- t0 = $[1];
40
+ t1 = $[1];
41
}
42
- let t1;
43
- if ($[2] !== b || $[3] !== t0) {
44
- t1 = {
45
- x: t0,
42
+ let t2;
43
+ if ($[2] !== b || $[3] !== t1) {
44
+ t2 = {
45
+ x: t1,
46
y() {
47
return [b];
48
},
49
};
50
$[2] = b;
51
- $[3] = t0;
52
- $[4] = t1;
51
+ $[3] = t1;
52
+ $[4] = t2;
53
} else {
54
- t1 = $[4];
54
+ t2 = $[4];
55
}
56
- return t1;
56
+ return t2;
57
}
58
59
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md
+19
-19
@@ -27,42 +27,42 @@ export const FIXTURE_ENTRYPOINT = {
27
import { unstable_useMemoCache as useMemoCache } from "react";
28
import { createHookWrapper } from "shared-runtime";
29
30
-function useHook(t16) {
30
+function useHook(t0) {
31
const $ = useMemoCache(8);
32
- const { a, b, c } = t16;
33
- let t0;
32
+ const { a, b, c } = t0;
33
+ let t1;
34
if ($[0] !== a) {
35
- t0 = [a];
35
+ t1 = [a];
36
$[0] = a;
37
- $[1] = t0;
37
+ $[1] = t1;
38
} else {
39
- t0 = $[1];
39
+ t1 = $[1];
40
}
41
- let t1;
42
- if ($[2] !== b || $[3] !== c || $[4] !== t0) {
43
- let t2;
41
+ let t2;
42
+ if ($[2] !== b || $[3] !== c || $[4] !== t1) {
43
+ let t3;
44
if ($[6] !== c) {
45
- t2 = { c };
45
+ t3 = { c };
46
$[6] = c;
47
- $[7] = t2;
47
+ $[7] = t3;
48
} else {
49
- t2 = $[7];
49
+ t3 = $[7];
50
}
51
- t1 = {
52
- x: t0,
51
+ t2 = {
52
+ x: t1,
53
y() {
54
return [b];
55
},
56
- z: t2,
56
+ z: t3,
57
};
58
$[2] = b;
59
$[3] = c;
60
- $[4] = t0;
61
- $[5] = t1;
60
+ $[4] = t1;
61
+ $[5] = t2;
62
} else {
63
- t1 = $[5];
63
+ t2 = $[5];
64
}
65
- return t1;
65
+ return t2;
66
}
67
68
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-nested.expect.md
+7
-7
@@ -34,13 +34,13 @@ export const FIXTURE_ENTRYPOINT = {
34
import { useState, unstable_useMemoCache as useMemoCache } from "react";
35
import { createHookWrapper } from "shared-runtime";
36
37
-function useHook(t21) {
37
+function useHook(t0) {
38
const $ = useMemoCache(3);
39
- const { value } = t21;
39
+ const { value } = t0;
40
const [state] = useState(false);
41
- let t0;
41
+ let t1;
42
if ($[0] !== value || $[1] !== state) {
43
- t0 = {
43
+ t1 = {
44
getX() {
45
return {
46
a: [],
@@ -53,11 +53,11 @@ function useHook(t21) {
53
};
54
$[0] = value;
55
$[1] = state;
56
- $[2] = t0;
56
+ $[2] = t1;
57
} else {
58
- t0 = $[2];
58
+ t1 = $[2];
59
}
60
- return t0;
60
+ return t1;
61
}
62
63
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactive-control-dependency-phi-setState-type.expect.md
+2
-2
@@ -98,8 +98,8 @@ function Component(props) {
98
return t1;
99
}
100
101
-function Foo(t21) {
102
- const { cond, setX, setY, setState } = t21;
101
+function Foo(t0) {
102
+ const { cond, setX, setY, setState } = t0;
103
if (cond) {
104
invariant(setState === setX, "Expected the correct setState function");
105
} else {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactive-control-dependency-switch-condition.expect.md
+7
-7
@@ -44,9 +44,9 @@ export const FIXTURE_ENTRYPOINT = {
44
import { unstable_useMemoCache as useMemoCache } from "react";
45
const GLOBAL = 42;
46
47
-function Component(t14) {
47
+function Component(t0) {
48
const $ = useMemoCache(2);
49
- const { value } = t14;
49
+ const { value } = t0;
50
let x;
51
bb1: switch (GLOBAL) {
52
case value: {
@@ -57,15 +57,15 @@ function Component(t14) {
57
x = 2;
58
}
59
}
60
- let t0;
60
+ let t1;
61
if ($[0] !== x) {
62
- t0 = [x];
62
+ t1 = [x];
63
$[0] = x;
64
- $[1] = t0;
64
+ $[1] = t1;
65
} else {
66
- t0 = $[1];
66
+ t1 = $[1];
67
}
68
- return t0;
68
+ return t1;
69
}
70
71
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-testifelse.expect.md
+2
-2
@@ -37,9 +37,9 @@ export const FIXTURE_ENTRYPOINT = {
37
import { unstable_useMemoCache as useMemoCache } from "react";
38
import { setProperty } from "shared-runtime";
39
40
-function useFoo(t27) {
40
+function useFoo(t0) {
41
const $ = useMemoCache(3);
42
- const { o, branchCheck } = t27;
42
+ const { o, branchCheck } = t0;
43
let x;
44
if ($[0] !== branchCheck || $[1] !== o.value) {
45
x = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-aliased-not-added-to-dep-2.expect.md
+12
-12
@@ -17,29 +17,29 @@ function Foo({ a }) {
17
18
```javascript
19
import { unstable_useMemoCache as useMemoCache } from "react"; // @validateRefAccessDuringRender:false
20
-function Foo(t20) {
20
+function Foo(t0) {
21
const $ = useMemoCache(4);
22
- const { a } = t20;
22
+ const { a } = t0;
23
const ref = useRef();
24
const val = ref.current;
25
- let t0;
25
+ let t1;
26
if ($[0] !== a) {
27
- t0 = { a, val };
27
+ t1 = { a, val };
28
$[0] = a;
29
- $[1] = t0;
29
+ $[1] = t1;
30
} else {
31
- t0 = $[1];
31
+ t1 = $[1];
32
}
33
- const x = t0;
34
- let t1;
33
+ const x = t1;
34
+ let t2;
35
if ($[2] !== x) {
36
- t1 = <VideoList videos={x} />;
36
+ t2 = <VideoList videos={x} />;
37
$[2] = x;
38
- $[3] = t1;
38
+ $[3] = t2;
39
} else {
40
- t1 = $[3];
40
+ t2 = $[3];
41
}
42
- return t1;
42
+ return t2;
43
}
44
45
```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep-2.expect.md
+12
-12
@@ -16,28 +16,28 @@ function Foo({ a }) {
16
17
```javascript
18
import { unstable_useMemoCache as useMemoCache } from "react"; // @validateRefAccessDuringRender:false
19
-function Foo(t17) {
19
+function Foo(t0) {
20
const $ = useMemoCache(4);
21
- const { a } = t17;
21
+ const { a } = t0;
22
const ref = useRef();
23
- let t0;
23
+ let t1;
24
if ($[0] !== a) {
25
- t0 = { a, val: ref.current };
25
+ t1 = { a, val: ref.current };
26
$[0] = a;
27
- $[1] = t0;
27
+ $[1] = t1;
28
} else {
29
- t0 = $[1];
29
+ t1 = $[1];
30
}
31
- const x = t0;
32
- let t1;
31
+ const x = t1;
32
+ let t2;
33
if ($[2] !== x) {
34
- t1 = <VideoList videos={x} />;
34
+ t2 = <VideoList videos={x} />;
35
$[2] = x;
36
- $[3] = t1;
36
+ $[3] = t2;
37
} else {
38
- t1 = $[3];
38
+ t2 = $[3];
39
}
40
- return t1;
40
+ return t2;
41
}
42
43
```
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dce-circular-reference.expect.md
+7
-7
@@ -34,24 +34,24 @@ export const FIXTURE_ENTRYPOINT = {
34
import { unstable_useMemoCache as useMemoCache } from "react";
35
import { identity } from "shared-runtime";
36
37
-function Component(t25) {
37
+function Component(t0) {
38
const $ = useMemoCache(2);
39
- const { data } = t25;
39
+ const { data } = t0;
40
let x = 0;
41
for (const item of data) {
42
const { current, other } = item;
43
x = x + current;
44
identity(other);
45
}
46
- let t0;
46
+ let t1;
47
if ($[0] !== x) {
48
- t0 = [x];
48
+ t1 = [x];
49
$[0] = x;
50
- $[1] = t0;
50
+ $[1] = t1;
51
} else {
52
- t0 = $[1];
52
+ t1 = $[1];
53
}
54
- return t0;
54
+ return t1;
55
}
56
57
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-duplicate-instruction-from-merge-consecutive-scopes.expect.md
+16
-16
@@ -28,31 +28,31 @@ export const FIXTURE_ENTRYPOINT = {
28
import { unstable_useMemoCache as useMemoCache } from "react";
29
import { Stringify } from "shared-runtime";
30
31
-function Component(t23) {
31
+function Component(t0) {
32
const $ = useMemoCache(3);
33
- const { id } = t23;
34
- let t0;
33
+ const { id } = t0;
34
+ let t1;
35
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36
- t0 = <Stringify title={undefined} />;
37
- $[0] = t0;
36
+ t1 = <Stringify title={undefined} />;
37
+ $[0] = t1;
38
} else {
39
- t0 = $[0];
39
+ t1 = $[0];
40
}
41
- const t1 = id ? true : false;
42
- let t2;
43
- if ($[1] !== t1) {
44
- t2 = (
41
+ const t2 = id ? true : false;
42
+ let t3;
43
+ if ($[1] !== t2) {
44
+ t3 = (
45
<>
46
- {t0}
47
- <Stringify title={t1} />
46
+ {t1}
47
+ <Stringify title={t2} />
48
</>
49
);
50
- $[1] = t1;
51
- $[2] = t2;
50
+ $[1] = t2;
51
+ $[2] = t3;
52
} else {
53
- t2 = $[2];
53
+ t3 = $[2];
54
}
55
- return t2;
55
+ return t3;
56
}
57
58
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-false-positive-preserve-memoization-nonescaping-invoked-callback-escaping-return.expect.md
+29
-29
@@ -39,58 +39,58 @@ export const FIXTURE_ENTRYPOINT = {
39
// @validatePreserveExistingMemoizationGuarantees @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
40
import { useCallback, unstable_useMemoCache as useMemoCache } from "react";
41
42
-function Component(t26) {
42
+function Component(t0) {
43
const $ = useMemoCache(11);
44
- const { entity, children } = t26;
45
- let t0;
44
+ const { entity, children } = t0;
45
+ let t1;
46
if ($[0] !== entity) {
47
- t0 = () => entity != null;
47
+ t1 = () => entity != null;
48
$[0] = entity;
49
- $[1] = t0;
49
+ $[1] = t1;
50
} else {
51
- t0 = $[1];
51
+ t1 = $[1];
52
}
53
- const showMessage = t0;
54
- let t1;
53
+ const showMessage = t1;
54
+ let t2;
55
if ($[2] !== showMessage) {
56
- t1 = showMessage();
56
+ t2 = showMessage();
57
$[2] = showMessage;
58
- $[3] = t1;
58
+ $[3] = t2;
59
} else {
60
- t1 = $[3];
60
+ t2 = $[3];
61
}
62
- const shouldShowMessage = t1;
63
- let t2;
62
+ const shouldShowMessage = t2;
63
+ let t3;
64
if ($[4] !== shouldShowMessage) {
65
- t2 = <div>{shouldShowMessage}</div>;
65
+ t3 = <div>{shouldShowMessage}</div>;
66
$[4] = shouldShowMessage;
67
- $[5] = t2;
67
+ $[5] = t3;
68
} else {
69
- t2 = $[5];
69
+ t3 = $[5];
70
}
71
- let t3;
71
+ let t4;
72
if ($[6] !== children) {
73
- t3 = <div>{children}</div>;
73
+ t4 = <div>{children}</div>;
74
$[6] = children;
75
- $[7] = t3;
75
+ $[7] = t4;
76
} else {
77
- t3 = $[7];
77
+ t4 = $[7];
78
}
79
- let t4;
80
- if ($[8] !== t2 || $[9] !== t3) {
81
- t4 = (
79
+ let t5;
80
+ if ($[8] !== t3 || $[9] !== t4) {
81
+ t5 = (
82
<div>
83
- {t2}
83
{t3}
84
+ {t4}
85
</div>
86
);
87
- $[8] = t2;
88
- $[9] = t3;
89
- $[10] = t4;
87
+ $[8] = t3;
88
+ $[9] = t4;
89
+ $[10] = t5;
90
} else {
91
- t4 = $[10];
91
+ t5 = $[10];
92
}
93
- return t4;
93
+ return t5;
94
}
95
96
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-false-positive-preserve-memoization-nonescaping-value.expect.md
+7
-7
@@ -36,23 +36,23 @@ export const FIXTURE_ENTRYPOINT = {
36
// @validatePreserveExistingMemoizationGuarantees @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
37
import { useCallback, unstable_useMemoCache as useMemoCache } from "react";
38
39
-function Component(t23) {
39
+function Component(t0) {
40
const $ = useMemoCache(2);
41
- const { entity, children } = t23;
41
+ const { entity, children } = t0;
42
43
const showMessage = () => entity != null;
44
if (!showMessage()) {
45
return children;
46
}
47
- let t0;
47
+ let t1;
48
if ($[0] !== children) {
49
- t0 = <div>{children}</div>;
49
+ t1 = <div>{children}</div>;
50
$[0] = children;
51
- $[1] = t0;
51
+ $[1] = t1;
52
} else {
53
- t0 = $[1];
53
+ t1 = $[1];
54
}
55
- return t0;
55
+ return t1;
56
}
57
58
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-array-pattern.expect.md
+7
-7
@@ -17,19 +17,19 @@ export const FIXTURE_ENTRYPOINT = {
17
18
```javascript
19
import { unstable_useMemoCache as useMemoCache } from "react";
20
-function Component(foo, ...t9) {
20
+function Component(foo, ...t0) {
21
const $ = useMemoCache(3);
22
- const [bar] = t9;
23
- let t0;
22
+ const [bar] = t0;
23
+ let t1;
24
if ($[0] !== foo || $[1] !== bar) {
25
- t0 = [foo, bar];
25
+ t1 = [foo, bar];
26
$[0] = foo;
27
$[1] = bar;
28
- $[2] = t0;
28
+ $[2] = t1;
29
} else {
30
- t0 = $[2];
30
+ t1 = $[2];
31
}
32
- return t0;
32
+ return t1;
33
}
34
35
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-identifier.expect.md
+7
-7
@@ -17,19 +17,19 @@ export const FIXTURE_ENTRYPOINT = {
17
18
```javascript
19
import { unstable_useMemoCache as useMemoCache } from "react";
20
-function Component(foo, ...t9) {
20
+function Component(foo, ...t0) {
21
const $ = useMemoCache(3);
22
- const bar = t9;
23
- let t0;
22
+ const bar = t0;
23
+ let t1;
24
if ($[0] !== foo || $[1] !== bar) {
25
- t0 = [foo, bar];
25
+ t1 = [foo, bar];
26
$[0] = foo;
27
$[1] = bar;
28
- $[2] = t0;
28
+ $[2] = t1;
29
} else {
30
- t0 = $[2];
30
+ t1 = $[2];
31
}
32
- return t0;
32
+ return t1;
33
}
34
35
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-object-spread-pattern.expect.md
+7
-7
@@ -17,19 +17,19 @@ export const FIXTURE_ENTRYPOINT = {
17
18
```javascript
19
import { unstable_useMemoCache as useMemoCache } from "react";
20
-function Component(foo, ...t9) {
20
+function Component(foo, ...t0) {
21
const $ = useMemoCache(3);
22
- const { bar } = t9;
23
- let t0;
22
+ const { bar } = t0;
23
+ let t1;
24
if ($[0] !== foo || $[1] !== bar) {
25
- t0 = [foo, bar];
25
+ t1 = [foo, bar];
26
$[0] = foo;
27
$[1] = bar;
28
- $[2] = t0;
28
+ $[2] = t1;
29
} else {
30
- t0 = $[2];
30
+ t1 = $[2];
31
}
32
- return t0;
32
+ return t1;
33
}
34
35
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md
+15
-15
@@ -33,29 +33,29 @@ export const FIXTURE_ENTRYPOINT = {
33
import { unstable_useMemoCache as useMemoCache } from "react";
34
import { Stringify } from "shared-runtime";
35
36
-function Component(t29) {
36
+function Component(t0) {
37
const $ = useMemoCache(8);
38
- const { useFeature } = t29;
38
+ const { useFeature } = t0;
39
let x;
40
if (useFeature) {
41
- const t0 = useFeature + useFeature;
42
- let t1;
43
- if ($[0] !== t0 || $[1] !== useFeature) {
44
- t1 = [t0].push(-useFeature);
45
- $[0] = t0;
41
+ const t1 = useFeature + useFeature;
42
+ let t2;
43
+ if ($[0] !== t1 || $[1] !== useFeature) {
44
+ t2 = [t1].push(-useFeature);
45
+ $[0] = t1;
46
$[1] = useFeature;
47
- $[2] = t1;
47
+ $[2] = t2;
48
} else {
49
- t1 = $[2];
49
+ t2 = $[2];
50
}
51
- x = t1;
51
+ x = t2;
52
}
53
54
const y = useFeature;
55
const z = useFeature.useProperty;
56
- let t0;
56
+ let t1;
57
if ($[3] !== useFeature || $[4] !== x || $[5] !== y || $[6] !== z) {
58
- t0 = (
58
+ t1 = (
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] = t0;
69
+ $[7] = t1;
70
} else {
71
- t0 = $[7];
71
+ t1 = $[7];
72
}
73
- return t0;
73
+ return t1;
74
}
75
76
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-alias-try-values.expect.md
+2
-2
@@ -39,8 +39,8 @@ function Component(props) {
39
x = [];
40
try {
41
throwInput(x);
42
- } catch (t27) {
43
- const e = t27;
42
+ } catch (t0) {
43
+ const e = t0;
44
45
y = e;
46
}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch-escaping.expect.md
+2
-2
@@ -38,8 +38,8 @@ function Component(props) {
38
const y = [];
39
y.push(props.y);
40
throwInput(y);
41
- } catch (t30) {
42
- const e = t30;
41
+ } catch (t0) {
42
+ const e = t0;
43
e.push(props.e);
44
x = e;
45
}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md
+2
-2
@@ -39,8 +39,8 @@ function Component(props) {
39
const y = [];
40
y.push(props.y);
41
throwInput(y);
42
- } catch (t25) {
43
- const e = t25;
42
+ } catch (t1) {
43
+ const e = t1;
44
e.push(props.e);
45
t0 = e;
46
break bb18;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md
+2
-2
@@ -39,8 +39,8 @@ function Component(props) {
39
const x = [];
40
try {
41
throwInput(x);
42
- } catch (t22) {
43
- const e = t22;
42
+ } catch (t1) {
43
+ const e = t1;
44
e.push(null);
45
t0 = e;
46
break bb11;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-on-function-parameter-1.expect.md
+9
-9
@@ -24,18 +24,18 @@ export const FIXTURE_ENTRYPOINT = {
24
25
```javascript
26
import { unstable_useMemoCache as useMemoCache } from "react";
27
-function Component(t38) {
27
+function Component(t0) {
28
const $ = useMemoCache(10);
29
- let { a, b: t40, c: t41 } = t38;
30
- let [b] = t40;
31
- let { c } = t41;
29
+ let { a, b: t1, c: t2 } = t0;
30
+ let [b] = t1;
31
+ let { c } = t2;
32
const d = a++;
33
const e = ++a;
34
const f = b--;
35
const g = --b;
36
const h = c++;
37
const i = --c;
38
- let t0;
38
+ let t3;
39
if (
40
$[0] !== a ||
41
$[1] !== b ||
@@ -47,7 +47,7 @@ function Component(t38) {
47
$[7] !== h ||
48
$[8] !== i
49
) {
50
- t0 = [a, b, c, d, e, f, g, h, i];
50
+ t3 = [a, b, c, d, e, f, g, h, i];
51
$[0] = a;
52
$[1] = b;
53
$[2] = c;
@@ -57,11 +57,11 @@ function Component(t38) {
57
$[6] = g;
58
$[7] = h;
59
$[8] = i;
60
- $[9] = t0;
60
+ $[9] = t3;
61
} else {
62
- t0 = $[9];
62
+ t3 = $[9];
63
}
64
- return t0;
64
+ return t3;
65
}
66
67
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-on-function-parameter-3.expect.md
+7
-7
@@ -20,22 +20,22 @@ export const FIXTURE_ENTRYPOINT = {
20
21
```javascript
22
import { unstable_useMemoCache as useMemoCache } from "react";
23
-function Component(t14) {
23
+function Component(t0) {
24
const $ = useMemoCache(4);
25
- let { c } = t14;
25
+ let { c } = t0;
26
const h = c++;
27
const i = --c;
28
- let t0;
28
+ let t1;
29
if ($[0] !== c || $[1] !== h || $[2] !== i) {
30
- t0 = [c, h, i];
30
+ t1 = [c, h, i];
31
$[0] = c;
32
$[1] = h;
33
$[2] = i;
34
- $[3] = t0;
34
+ $[3] = t1;
35
} else {
36
- t0 = $[3];
36
+ t1 = $[3];
37
}
38
- return t0;
38
+ return t1;
39
}
40
41
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-on-function-parameter-4.expect.md
+7
-7
@@ -20,22 +20,22 @@ export const FIXTURE_ENTRYPOINT = {
20
21
```javascript
22
import { unstable_useMemoCache as useMemoCache } from "react";
23
-function Component(t14) {
23
+function Component(t0) {
24
const $ = useMemoCache(4);
25
- let [b] = t14;
25
+ let [b] = t0;
26
const f = b--;
27
const g = --b;
28
- let t0;
28
+ let t1;
29
if ($[0] !== b || $[1] !== f || $[2] !== g) {
30
- t0 = [b, f, g];
30
+ t1 = [b, f, g];
31
$[0] = b;
32
$[1] = f;
33
$[2] = g;
34
- $[3] = t0;
34
+ $[3] = t1;
35
} else {
36
- t0 = $[3];
36
+ t1 = $[3];
37
}
38
- return t0;
38
+ return t1;
39
}
40
41
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useCallback-set-ref-nested-property.expect.md
+16
-16
@@ -36,35 +36,35 @@ import {
36
37
// Identical to useCallback-set-ref-nested-property-preserve-memoization,
38
// but with a different set of compiler flags
39
-function Component(t27) {
39
+function Component(t0) {
40
const $ = useMemoCache(4);
41
- let t0;
41
+ let t1;
42
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
43
- t0 = { inner: null };
44
- $[0] = t0;
43
+ t1 = { inner: null };
44
+ $[0] = t1;
45
} else {
46
- t0 = $[0];
46
+ t1 = $[0];
47
}
48
- const ref = useRef(t0);
49
- let t1;
48
+ const ref = useRef(t1);
49
+ let t2;
50
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
51
- t1 = (event) => {
51
+ t2 = (event) => {
52
ref.current.inner = event.target.value;
53
};
54
- $[1] = t1;
54
+ $[1] = t2;
55
} else {
56
- t1 = $[1];
56
+ t2 = $[1];
57
}
58
- const onChange = t1;
59
- let t2;
58
+ const onChange = t2;
59
+ let t3;
60
if ($[2] !== onChange) {
61
- t2 = <input onChange={onChange} />;
61
+ t3 = <input onChange={onChange} />;
62
$[2] = onChange;
63
- $[3] = t2;
63
+ $[3] = t3;
64
} else {
65
- t2 = $[3];
65
+ t3 = $[3];
66
}
67
- return t2;
67
+ return t3;
68
}
69
70
export const FIXTURE_ENTRYPOINT = {