1
+
2
+## Input
3
+
4
+```javascript
5
+import { ValidateMemoization } from "shared-runtime";
6
+
7
+// Achieving Forget's level of memoization precision in this example isn't possible with useMemo
8
+// without significantly altering the code, so disable the non-Forget evaluation of this fixture.
9
+// @disableNonForgetInSprout
10
+function Component({ a, b, c }) {
11
+ const x = [];
12
+ let y;
13
+ if (a) {
14
+ y = [b];
15
+ }
16
+ x.push(c);
17
+
18
+ // this scope should not merge with the above scope because y does not invalidate
19
+ // on changes to `c`
20
+ const z = [y];
21
+
22
+ // return [x, z];
23
+ return (
24
+ <>
25
+ <ValidateMemoization inputs={[a, b, c]} output={x} />
26
+ <ValidateMemoization inputs={[a, b]} output={z} />
27
+ </>
28
+ );
29
+}
30
+
31
+export const FIXTURE_ENTRYPOINT = {
32
+ fn: Component,
33
+ params: [{ a: false, b: null, c: 0 }],
34
+ sequentialRenders: [
35
+ { a: false, b: null, c: 0 },
36
+ { a: false, b: null, c: 1 },
37
+ { a: true, b: 0, c: 1 },
38
+ { a: true, b: 1, c: 1 },
39
+ ],
40
+};
41
+
42
+```
43
+
44
+## Code
45
+
46
+```javascript
47
+import { c as _c } from "react/compiler-runtime";
48
+import { ValidateMemoization } from "shared-runtime";
49
+
50
+// Achieving Forget's level of memoization precision in this example isn't possible with useMemo
51
+// without significantly altering the code, so disable the non-Forget evaluation of this fixture.
52
+// @disableNonForgetInSprout
53
+function Component(t0) {
54
+ const $ = _c(25);
55
+ const { a, b, c } = t0;
56
+ let y;
57
+ let x;
58
+ if ($[0] !== a || $[1] !== b || $[2] !== c) {
59
+ x = [];
60
+ if (a) {
61
+ let t1;
62
+ if ($[5] !== b) {
63
+ t1 = [b];
64
+ $[5] = b;
65
+ $[6] = t1;
66
+ } else {
67
+ t1 = $[6];
68
+ }
69
+ y = t1;
70
+ }
71
+
72
+ x.push(c);
73
+ $[0] = a;
74
+ $[1] = b;
75
+ $[2] = c;
76
+ $[3] = y;
77
+ $[4] = x;
78
+ } else {
79
+ y = $[3];
80
+ x = $[4];
81
+ }
82
+ let t1;
83
+ if ($[7] !== y) {
84
+ t1 = [y];
85
+ $[7] = y;
86
+ $[8] = t1;
87
+ } else {
88
+ t1 = $[8];
89
+ }
90
+ const z = t1;
91
+ let t2;
92
+ if ($[9] !== a || $[10] !== b || $[11] !== c) {
93
+ t2 = [a, b, c];
94
+ $[9] = a;
95
+ $[10] = b;
96
+ $[11] = c;
97
+ $[12] = t2;
98
+ } else {
99
+ t2 = $[12];
100
+ }
101
+ let t3;
102
+ if ($[13] !== t2 || $[14] !== x) {
103
+ t3 = <ValidateMemoization inputs={t2} output={x} />;
104
+ $[13] = t2;
105
+ $[14] = x;
106
+ $[15] = t3;
107
+ } else {
108
+ t3 = $[15];
109
+ }
110
+ let t4;
111
+ if ($[16] !== a || $[17] !== b) {
112
+ t4 = [a, b];
113
+ $[16] = a;
114
+ $[17] = b;
115
+ $[18] = t4;
116
+ } else {
117
+ t4 = $[18];
118
+ }
119
+ let t5;
120
+ if ($[19] !== t4 || $[20] !== z) {
121
+ t5 = <ValidateMemoization inputs={t4} output={z} />;
122
+ $[19] = t4;
123
+ $[20] = z;
124
+ $[21] = t5;
125
+ } else {
126
+ t5 = $[21];
127
+ }
128
+ let t6;
129
+ if ($[22] !== t3 || $[23] !== t5) {
130
+ t6 = (
131
+ <>
132
+ {t3}
133
+ {t5}
134
+ </>
135
+ );
136
+ $[22] = t3;
137
+ $[23] = t5;
138
+ $[24] = t6;
139
+ } else {
140
+ t6 = $[24];
141
+ }
142
+ return t6;
143
+}
144
+
145
+export const FIXTURE_ENTRYPOINT = {
146
+ fn: Component,
147
+ params: [{ a: false, b: null, c: 0 }],
148
+ sequentialRenders: [
149
+ { a: false, b: null, c: 0 },
150
+ { a: false, b: null, c: 1 },
151
+ { a: true, b: 0, c: 1 },
152
+ { a: true, b: 1, c: 1 },
153
+ ],
154
+};
155
+
156
+```
157
+
158
+### Eval output
159
+(kind: ok) <div>{"inputs":[false,null,0],"output":[0]}</div><div>{"inputs":[false,null],"output":[null]}</div>
160
+<div>{"inputs":[false,null,1],"output":[1]}</div><div>{"inputs":[false,null],"output":[null]}</div>
161
+<div>{"inputs":[true,0,1],"output":[1]}</div><div>{"inputs":[true,0],"output":[[0]]}</div>
162
+<div>{"inputs":[true,1,1],"output":[1]}</div><div>{"inputs":[true,1],"output":[[1]]}</div>
\ No newline at end of file