Skip to content

Commit 59a0fcf

Browse files
committed
[compiler] Fix <ValidateMemoization>
By accident we were only ever checking the compiled output, but the intention was in general to be able to compare memoization with/without forget.
1 parent 359717a commit 59a0fcf

21 files changed

+141
-74
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/todo-control-flow-sensitive-mutation.expect.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@ function Component({a, b, c}: {a: number; b: number; c: number}) {
2323

2424
return (
2525
<>
26-
<ValidateMemoization inputs={[a, b, c]} output={x} alwaysCheck={true} />;
26+
<ValidateMemoization inputs={[a, b, c]} output={x} />;
2727
{/* TODO: should only depend on c */}
28-
<ValidateMemoization
29-
inputs={[a, b, c]}
30-
output={x[0]}
31-
alwaysCheck={true}
32-
/>
33-
;
28+
<ValidateMemoization inputs={[a, b, c]} output={x[0]} />;
3429
</>
3530
);
3631
}
@@ -98,7 +93,7 @@ function Component(t0) {
9893
}
9994
let t3;
10095
if ($[9] !== t2 || $[10] !== x) {
101-
t3 = <ValidateMemoization inputs={t2} output={x} alwaysCheck={true} />;
96+
t3 = <ValidateMemoization inputs={t2} output={x} />;
10297
$[9] = t2;
10398
$[10] = x;
10499
$[11] = t3;
@@ -117,7 +112,7 @@ function Component(t0) {
117112
}
118113
let t5;
119114
if ($[16] !== t4 || $[17] !== x[0]) {
120-
t5 = <ValidateMemoization inputs={t4} output={x[0]} alwaysCheck={true} />;
115+
t5 = <ValidateMemoization inputs={t4} output={x[0]} />;
121116
$[16] = t4;
122117
$[17] = x[0];
123118
$[18] = t5;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/todo-control-flow-sensitive-mutation.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ function Component({a, b, c}: {a: number; b: number; c: number}) {
1919

2020
return (
2121
<>
22-
<ValidateMemoization inputs={[a, b, c]} output={x} alwaysCheck={true} />;
22+
<ValidateMemoization inputs={[a, b, c]} output={x} />;
2323
{/* TODO: should only depend on c */}
24-
<ValidateMemoization
25-
inputs={[a, b, c]}
26-
output={x[0]}
27-
alwaysCheck={true}
28-
/>
29-
;
24+
<ValidateMemoization inputs={[a, b, c]} output={x[0]} />;
3025
</>
3126
);
3227
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/todo-transitivity-createfrom-capture-lambda.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Component({a, b}) {
2222
typedMutate(z, b);
2323

2424
// TODO: this *should* only depend on `a`
25-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
25+
return <ValidateMemoization inputs={[a, b]} output={x} />;
2626
}
2727

2828
export const FIXTURE_ENTRYPOINT = {
@@ -86,7 +86,7 @@ function Component(t0) {
8686
}
8787
let t3;
8888
if ($[7] !== t2 || $[8] !== x) {
89-
t3 = <ValidateMemoization inputs={t2} output={x} alwaysCheck={true} />;
89+
t3 = <ValidateMemoization inputs={t2} output={x} />;
9090
$[7] = t2;
9191
$[8] = x;
9292
$[9] = t3;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/todo-transitivity-createfrom-capture-lambda.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Component({a, b}) {
1818
typedMutate(z, b);
1919

2020
// TODO: this *should* only depend on `a`
21-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
21+
return <ValidateMemoization inputs={[a, b]} output={x} />;
2222
}
2323

2424
export const FIXTURE_ENTRYPOINT = {

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-add-captured-array-to-itself.expect.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function Component({a, b}) {
2020

2121
return (
2222
<>
23-
<ValidateMemoization inputs={[a]} output={o} alwaysCheck={true} />;
24-
<ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
23+
<ValidateMemoization inputs={[a]} output={o} />;
24+
<ValidateMemoization inputs={[a, b]} output={x} />;
2525
</>
2626
);
2727
}
@@ -92,7 +92,7 @@ function Component(t0) {
9292
}
9393
let t5;
9494
if ($[8] !== o || $[9] !== t4) {
95-
t5 = <ValidateMemoization inputs={t4} output={o} alwaysCheck={true} />;
95+
t5 = <ValidateMemoization inputs={t4} output={o} />;
9696
$[8] = o;
9797
$[9] = t4;
9898
$[10] = t5;
@@ -110,7 +110,7 @@ function Component(t0) {
110110
}
111111
let t7;
112112
if ($[14] !== t6 || $[15] !== x) {
113-
t7 = <ValidateMemoization inputs={t6} output={x} alwaysCheck={true} />;
113+
t7 = <ValidateMemoization inputs={t6} output={x} />;
114114
$[14] = t6;
115115
$[15] = x;
116116
$[16] = t7;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-add-captured-array-to-itself.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function Component({a, b}) {
1616

1717
return (
1818
<>
19-
<ValidateMemoization inputs={[a]} output={o} alwaysCheck={true} />;
20-
<ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
19+
<ValidateMemoization inputs={[a]} output={o} />;
20+
<ValidateMemoization inputs={[a, b]} output={x} />;
2121
</>
2222
);
2323
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-capture-createfrom-lambda.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Component({a, b}: {a: number; b: number}) {
2121
// mutates x
2222
typedMutate(z, b);
2323

24-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
24+
return <ValidateMemoization inputs={[a, b]} output={x} />;
2525
}
2626

2727
export const FIXTURE_ENTRYPOINT = {
@@ -85,7 +85,7 @@ function Component(t0) {
8585
}
8686
let t3;
8787
if ($[7] !== t2 || $[8] !== x) {
88-
t3 = <ValidateMemoization inputs={t2} output={x} alwaysCheck={true} />;
88+
t3 = <ValidateMemoization inputs={t2} output={x} />;
8989
$[7] = t2;
9090
$[8] = x;
9191
$[9] = t3;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-capture-createfrom-lambda.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Component({a, b}: {a: number; b: number}) {
1717
// mutates x
1818
typedMutate(z, b);
1919

20-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
20+
return <ValidateMemoization inputs={[a, b]} output={x} />;
2121
}
2222

2323
export const FIXTURE_ENTRYPOINT = {

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-capture-createfrom.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Component({a, b}: {a: number; b: number}) {
1717
// mutates x
1818
typedMutate(z, b);
1919

20-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
20+
return <ValidateMemoization inputs={[a, b]} output={x} />;
2121
}
2222

2323
export const FIXTURE_ENTRYPOINT = {
@@ -76,7 +76,7 @@ function Component(t0) {
7676
}
7777
let t3;
7878
if ($[7] !== t2 || $[8] !== x) {
79-
t3 = <ValidateMemoization inputs={t2} output={x} alwaysCheck={true} />;
79+
t3 = <ValidateMemoization inputs={t2} output={x} />;
8080
$[7] = t2;
8181
$[8] = x;
8282
$[9] = t3;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/transitivity-capture-createfrom.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Component({a, b}: {a: number; b: number}) {
1313
// mutates x
1414
typedMutate(z, b);
1515

16-
return <ValidateMemoization inputs={[a, b]} output={x} alwaysCheck={true} />;
16+
return <ValidateMemoization inputs={[a, b]} output={x} />;
1717
}
1818

1919
export const FIXTURE_ENTRYPOINT = {

0 commit comments

Comments
 (0)