@samitouri / QOS-React / commits / 24fbeddcea

[test] Fix test to have initial value

Having undefined as the initial value makes this a primitive. There's a separate bug where we need to remove type inference for captured refs that get mutated but that's secondary -- we're currently not even marking the Identifier LHS as a captured ref. Fix the test to repro this bug for now.

Sathya Gunasekaran committed Mar 3, 2023 at 13:35 UTC 24fbeddcea3c293d55de912666e3598102b9ac73
2 files changed +17 -9
compiler/forget/src/__tests__/fixtures/hir/_bug.capturing-func-simple-alias.expect.md
+16 -8
@@ -4,7 +4,7 @@
4 ```javascript
5 function component(a) {
6 let x = { a };
7 - let y;
7 + let y = {};
8 (function () {
9 y = x;
10 })();
@@ -18,7 +18,7 @@ function component(a) {
18
19 ```javascript
20 function component(a) {
21 - const $ = React.unstable_useMemoCache(2);
21 + const $ = React.unstable_useMemoCache(4);
22 const c_0 = $[0] !== a;
23 let t0;
24 if (c_0) {
@@ -29,12 +29,20 @@ function component(a) {
29 t0 = $[1];
30 }
31 const x = t0;
32 -
33 - (function () {
34 - y = x;
35 - })();
36 - mutate(undefined);
37 - return undefined;
32 + const c_2 = $[2] !== x;
33 + let y;
34 + if (c_2) {
35 + y = {};
36 + (function () {
37 + y = x;
38 + })();
39 + mutate(y);
40 + $[2] = x;
41 + $[3] = y;
42 + } else {
43 + y = $[3];
44 + }
45 + return y;
46 }
47
48 ```
compiler/forget/src/__tests__/fixtures/hir/_bug.capturing-func-simple-alias.js
+1 -1
@@ -1,6 +1,6 @@
1 function component(a) {
2 let x = { a };
3 - let y;
3 + let y = {};
4 (function () {
5 y = x;
6 })();