@samitouri / QOS-React-2 / commits / 69e34270a2

Factor out assignment lowering to allow generating multiple instructions

Joe Savona committed Dec 21, 2022 at 10:02 UTC 69e34270a2e3f1307f90b219039b18449bd96ae2
13 files changed +91 -74
compiler/forget/src/HIR/BuildHIR.ts
+25 -8
@@ -623,7 +623,7 @@ function lowerStatement(
623 const kind =
624 nodeKind === "let" ? InstructionKind.Let : InstructionKind.Const;
625 for (const declaration of stmt.get("declarations")) {
626 - const id = lowerLVal(builder, declaration.get("id"));
626 + const id = declaration.get("id");
627 const init = declaration.get("init");
628 let value: InstructionValue;
629 if (init.hasNode()) {
@@ -632,15 +632,16 @@ function lowerStatement(
632 value = {
633 kind: "Primitive",
634 value: undefined,
635 - loc: id.loc,
635 + loc: id.node.loc ?? GeneratedSource,
636 };
637 }
638 - builder.push({
639 - id: makeInstructionId(0),
640 - lvalue: { place: id, kind },
641 - value,
642 - loc: declaration.node.loc ?? GeneratedSource,
643 - });
638 + lowerAssignment(
639 + builder,
640 + stmt.node.loc ?? GeneratedSource,
641 + kind,
642 + id,
643 + value
644 + );
645 }
646 return;
647 }
@@ -1343,3 +1344,19 @@ function lowerLVal(builder: HIRBuilder, exprPath: NodePath<t.LVal>): Place {
1344 }
1345 }
1346 }
1347 +
1348 +function lowerAssignment(
1349 + builder: HIRBuilder,
1350 + loc: SourceLocation,
1351 + kind: InstructionKind,
1352 + lvalue: NodePath<t.LVal>,
1353 + value: InstructionValue
1354 +): void {
1355 + const id = lowerLVal(builder, lvalue);
1356 + builder.push({
1357 + id: makeInstructionId(0),
1358 + lvalue: { place: id, kind },
1359 + value,
1360 + loc,
1361 + });
1362 +}
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+6 -6
@@ -38,9 +38,9 @@ bb0:
38 [1] Const mutate items$30:TProp = read props$29.items
39 [2] Const mutate maxItems$31:TProp = read props$29.maxItems
40 [3] Const mutate renderedItems$32_@0:TPrimitive[3:33] = Array []
41 - [4] Const mutate seen$33_@0[3:33] = New mutate Set$6()
41 + [4] Const mutate seen$33_@0[3:33] = New mutate Set$5()
42 [5] Const mutate $34:TPrimitive = 0
43 - [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp)
43 + [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$7.max(read $34:TPrimitive, read maxItems$31:TProp)
44 [7] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
45 bb3:
46 predecessor blocks: bb0
@@ -114,10 +114,10 @@ function Component(
114 [2] Const mutate maxItems$31:TProp = read props$29.maxItems
115 scope @0 [3:33] deps=[read maxItems$31:TProp, read items$30.length, read items$30] out=[renderedItems$32_@0] {
116 [3] Const mutate renderedItems$32_@0:TPrimitive[3:33] = Array []
117 - [4] Const mutate seen$33_@0[3:33] = New mutate Set$6()
117 + [4] Const mutate seen$33_@0[3:33] = New mutate Set$5()
118 [5] Const mutate $34:TPrimitive = 0
119 scope @2 [6:7] deps=[read maxItems$31:TProp] out=[max$35_@2] {
120 - [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp)
120 + [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$7.max(read $34:TPrimitive, read maxItems$31:TProp)
121 }
122 for (
123 [8] Let mutate i$36_@0:TPrimitive[3:33] = 0
@@ -184,12 +184,12 @@ function Component$0(props$29) {
184 let renderedItems$32;
185 if (c_0 || c_1 || c_2) {
186 renderedItems$32 = [];
187 - const seen$33 = new Set$6();
187 + const seen$33 = new Set$5();
188 const c_4 = $[4] !== maxItems$31;
189 let max$35;
190
191 if (c_4) {
192 - max$35 = Math$8.max(0, maxItems$31);
192 + max$35 = Math$7.max(0, maxItems$31);
193 $[4] = maxItems$31;
194 $[5] = max$35;
195 } else {
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+3 -3
@@ -70,7 +70,7 @@ function foo$0() {}
70 ```
71 bb0:
72 [1] Const mutate x$11_@0 = Array []
73 - [2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
73 + [2] Const mutate y$12_@1 = Call read useFreeze$3:TFunction(freeze x$11_@0)
74 [3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
75 [4] Const mutate $13 = "\n "
76 [5] Const mutate $14 = "\n "
@@ -89,7 +89,7 @@ function Component(
89 [1] Const mutate x$11_@0 = Array []
90 }
91 scope @1 [2:3] deps=[freeze x$11_@0] out=[y$12_@1] {
92 - [2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
92 + [2] Const mutate y$12_@1 = Call read useFreeze$3:TFunction(freeze x$11_@0)
93 }
94 [3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
95 [4] Const mutate $13 = "\n "
@@ -120,7 +120,7 @@ function Component$0(props$10) {
120 let y$12;
121
122 if (c_1) {
123 - y$12 = useFreeze$4(x$11);
123 + y$12 = useFreeze$3(x$11);
124 $[1] = x$11;
125 $[2] = y$12;
126 } else {
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+6 -6
@@ -129,8 +129,8 @@ function Foo$0() {}
129
130 ```
131 bb0:
132 - [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a)
133 - [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b)
132 + [1] Const mutate a$9_@1[1:7] = Call mutate compute$2:TFunction(read props$8.a)
133 + [2] Const mutate b$10_@1[1:7] = Call mutate compute$2:TFunction(read props$8.b)
134 [3] If (read props$8.c) then:bb2 else:bb1 fallthrough=bb1
135 bb2:
136 predecessor blocks: bb0
@@ -150,8 +150,8 @@ function Component(
150 props,
151 ) {
152 scope @1 [1:7] deps=[read props$8.a, read props$8.b, read props$8.c] out=[a$9_@1] {
153 - [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a)
154 - [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b)
153 + [1] Const mutate a$9_@1[1:7] = Call mutate compute$2:TFunction(read props$8.a)
154 + [2] Const mutate b$10_@1[1:7] = Call mutate compute$2:TFunction(read props$8.b)
155 if (read props$8.c) {
156 [4] Call mutate mutate$5:TFunction(mutate a$9_@1)
157 [5] Call mutate mutate$5:TFunction(mutate b$10_@1)
@@ -175,8 +175,8 @@ function Component$0(props$8) {
175 const c_2 = $[2] !== props$8.c;
176 let a$9;
177 if (c_0 || c_1 || c_2) {
178 - a$9 = compute$3(props$8.a);
179 - const b$10 = compute$3(props$8.b);
178 + a$9 = compute$2(props$8.a);
179 + const b$10 = compute$2(props$8.b);
180
181 if (props$8.c) {
182 mutate$5(a$9);
compiler/forget/src/__tests__/fixtures/hir/independent.expect.md
+6 -6
@@ -28,8 +28,8 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$8_@0 = Call mutate compute$3:TFunction(read props$7.a)
32 - [2] Const mutate b$9_@1 = Call mutate compute$3:TFunction(read props$7.b)
31 + [1] Const mutate a$8_@0 = Call mutate compute$2:TFunction(read props$7.a)
32 + [2] Const mutate b$9_@1 = Call mutate compute$2:TFunction(read props$7.b)
33 [3] Const mutate t6$10_@2 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@1} ></read Foo$5>
34 [4] Return read t6$10_@2
35 ```
@@ -41,10 +41,10 @@ function Component(
41 props,
42 ) {
43 scope @0 [1:2] deps=[read props$7.a] out=[a$8_@0] {
44 - [1] Const mutate a$8_@0 = Call mutate compute$3:TFunction(read props$7.a)
44 + [1] Const mutate a$8_@0 = Call mutate compute$2:TFunction(read props$7.a)
45 }
46 scope @1 [2:3] deps=[read props$7.b] out=[b$9_@1] {
47 - [2] Const mutate b$9_@1 = Call mutate compute$3:TFunction(read props$7.b)
47 + [2] Const mutate b$9_@1 = Call mutate compute$2:TFunction(read props$7.b)
48 }
49 scope @2 [3:4] deps=[freeze a$8_@0, freeze b$9_@1] out=[$10_@2] {
50 [3] Const mutate $10_@2 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@1} ></read Foo$5>
@@ -62,7 +62,7 @@ function Component$0(props$7) {
62 const c_0 = $[0] !== props$7.a;
63 let a$8;
64 if (c_0) {
65 - a$8 = compute$3(props$7.a);
65 + a$8 = compute$2(props$7.a);
66 $[0] = props$7.a;
67 $[1] = a$8;
68 } else {
@@ -73,7 +73,7 @@ function Component$0(props$7) {
73 let b$9;
74
75 if (c_2) {
76 - b$9 = compute$3(props$7.b);
76 + b$9 = compute$2(props$7.b);
77 $[2] = props$7.b;
78 $[3] = b$9;
79 } else {
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+6 -6
@@ -100,8 +100,8 @@ function Foo$0() {}
100
101 ```
102 bb0:
103 - [1] Const mutate a$9_@0[1:6] = Call mutate compute$3:TFunction(read props$8.a)
104 - [2] Const mutate b$10_@0[1:6] = Call mutate compute$3:TFunction(read props$8.b)
103 + [1] Const mutate a$9_@0[1:6] = Call mutate compute$2:TFunction(read props$8.a)
104 + [2] Const mutate b$10_@0[1:6] = Call mutate compute$2:TFunction(read props$8.b)
105 [3] If (read props$8.c) then:bb2 else:bb1 fallthrough=bb1
106 bb2:
107 predecessor blocks: bb0
@@ -120,8 +120,8 @@ function Component(
120 props,
121 ) {
122 scope @0 [1:6] deps=[read props$8.a, read props$8.b, read props$8.c] out=[a$9_@0, b$10_@0] {
123 - [1] Const mutate a$9_@0[1:6] = Call mutate compute$3:TFunction(read props$8.a)
124 - [2] Const mutate b$10_@0[1:6] = Call mutate compute$3:TFunction(read props$8.b)
123 + [1] Const mutate a$9_@0[1:6] = Call mutate compute$2:TFunction(read props$8.a)
124 + [2] Const mutate b$10_@0[1:6] = Call mutate compute$2:TFunction(read props$8.b)
125 if (read props$8.c) {
126 [4] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
127 }
@@ -145,8 +145,8 @@ function Component$0(props$8) {
145 let a$9;
146 let b$10;
147 if (c_0 || c_1 || c_2) {
148 - a$9 = compute$3(props$8.a);
149 - b$10 = compute$3(props$8.b);
148 + a$9 = compute$2(props$8.a);
149 + b$10 = compute$2(props$8.b);
150
151 if (props$8.c) {
152 foo$5(a$9, b$10);
compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md
+6 -6
@@ -28,8 +28,8 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$9_@0[1:4] = Call mutate compute$3:TFunction(read props$8.a)
32 - [2] Const mutate b$10_@0[1:4] = Call mutate compute$3:TFunction(read props$8.b)
31 + [1] Const mutate a$9_@0[1:4] = Call mutate compute$2:TFunction(read props$8.a)
32 + [2] Const mutate b$10_@0[1:4] = Call mutate compute$2:TFunction(read props$8.b)
33 [3] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
34 [4] Const mutate t6$11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
35 [5] Return read t6$11_@1
@@ -42,8 +42,8 @@ function Component(
42 props,
43 ) {
44 scope @0 [1:4] deps=[read props$8.a, read props$8.b] out=[a$9_@0, b$10_@0] {
45 - [1] Const mutate a$9_@0[1:4] = Call mutate compute$3:TFunction(read props$8.a)
46 - [2] Const mutate b$10_@0[1:4] = Call mutate compute$3:TFunction(read props$8.b)
45 + [1] Const mutate a$9_@0[1:4] = Call mutate compute$2:TFunction(read props$8.a)
46 + [2] Const mutate b$10_@0[1:4] = Call mutate compute$2:TFunction(read props$8.b)
47 [3] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
48 }
49 scope @1 [4:5] deps=[freeze a$9_@0, freeze b$10_@0] out=[$11_@1] {
@@ -64,8 +64,8 @@ function Component$0(props$8) {
64 let a$9;
65 let b$10;
66 if (c_0 || c_1) {
67 - a$9 = compute$3(props$8.a);
68 - b$10 = compute$3(props$8.b);
67 + a$9 = compute$2(props$8.a);
68 + b$10 = compute$2(props$8.b);
69 foo$5(a$9, b$10);
70 $[0] = props$8.a;
71 $[1] = props$8.b;
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+6 -6
@@ -70,7 +70,7 @@ bb0:
70 [4] Const mutate d$14_@1:TObject[2:15] = Object { c: read c$13_@2:TObject }
71 [5] Const mutate x$15_@1:TObject[2:15] = Object { }
72 [6] Reassign store x$15_@1.b[2:15] = read b$12_@1
73 - [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
73 + [7] Const mutate y$16_@1[2:15] = Call mutate mutate$7:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
74 [8] If (read a$11_@0:TObject) then:bb1 else:bb1 fallthrough=bb1
75 bb1:
76 predecessor blocks: bb0
@@ -87,7 +87,7 @@ bb7:
87 bb9:
88 predecessor blocks: bb7
89 [13] Const mutate $17:TPrimitive = null
90 - [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
90 + [14] Call mutate mutate$7:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
91 [15] Return
92 ```
93
@@ -107,7 +107,7 @@ function Component(
107 [4] Const mutate d$14_@1:TObject[2:15] = Object { c: read c$13_@2:TObject }
108 [5] Const mutate x$15_@1:TObject[2:15] = Object { }
109 [6] Reassign store x$15_@1.b[2:15] = read b$12_@1
110 - [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
110 + [7] Const mutate y$16_@1[2:15] = Call mutate mutate$7:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
111 if (read a$11_@0:TObject) {
112 }
113 if (read b$12_@1) {
@@ -119,7 +119,7 @@ function Component(
119 if (read y$16_@1) {
120 }
121 [13] Const mutate $17:TPrimitive = null
122 - [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
122 + [14] Call mutate mutate$7:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
123 return
124 }
125
@@ -153,7 +153,7 @@ function Component$0(props$10) {
153 };
154 const x$15 = {};
155 x$15.b = b$12;
156 - const y$16 = mutate$8(x$15, d$14);
156 + const y$16 = mutate$7(x$15, d$14);
157
158 if (a$11) {
159 }
@@ -170,7 +170,7 @@ function Component$0(props$10) {
170 if (y$16) {
171 }
172
173 - mutate$8(x$15, null);
173 + mutate$7(x$15, null);
174 }
175
176 ```
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+3 -3
@@ -42,7 +42,7 @@ function Foo$0() {}
42 bb0:
43 [1] Const mutate a$7_@0[1:4] = Array []
44 [2] Const mutate b$8_@0:TObject[1:4] = Object { }
45 - [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0:TObject)
45 + [3] Const mutate c$9_@0[1:4] = New mutate Foo$4(mutate a$7_@0, mutate b$8_@0:TObject)
46 [4] Return freeze c$9_@0
47 ```
48
@@ -55,7 +55,7 @@ function Component(
55 scope @0 [1:4] deps=[] out=[c$9_@0] {
56 [1] Const mutate a$7_@0[1:4] = Array []
57 [2] Const mutate b$8_@0:TObject[1:4] = Object { }
58 - [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0:TObject)
58 + [3] Const mutate c$9_@0[1:4] = New mutate Foo$4(mutate a$7_@0, mutate b$8_@0:TObject)
59 }
60 return freeze c$9_@0
61 }
@@ -71,7 +71,7 @@ function Component$0(props$6) {
71 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
72 const a$7 = [];
73 const b$8 = {};
74 - c$9 = new Foo$5(a$7, b$8);
74 + c$9 = new Foo$4(a$7, b$8);
75 $[0] = c$9;
76 } else {
77 c$9 = $[0];
compiler/forget/src/__tests__/fixtures/hir/type-binary-operator.expect.md
+6 -6
@@ -16,8 +16,8 @@ function component() {
16
17 ```
18 bb0:
19 - [1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
20 - [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
19 + [1] Const mutate a$7_@0:TPrimitive = Call mutate some$1:TFunction()
20 + [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$3:TFunction()
21 [3] Const mutate $9:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
22 [4] If (read $9:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23 bb2:
@@ -35,10 +35,10 @@ bb1:
35 function component(
36 ) {
37 scope @0 [1:2] deps=[] out=[a$7_@0] {
38 - [1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
38 + [1] Const mutate a$7_@0:TPrimitive = Call mutate some$1:TFunction()
39 }
40 scope @1 [2:3] deps=[] out=[b$8_@1] {
41 - [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
41 + [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$3:TFunction()
42 }
43 [3] Const mutate $9:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
44 if (read $9:TPrimitive) {
@@ -56,7 +56,7 @@ function component$0() {
56 const $ = React.useMemoCache();
57 let a$7;
58 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
59 - a$7 = some$2();
59 + a$7 = some$1();
60 $[0] = a$7;
61 } else {
62 a$7 = $[0];
@@ -65,7 +65,7 @@ function component$0() {
65 let b$8;
66
67 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
68 - b$8 = someOther$4();
68 + b$8 = someOther$3();
69 $[1] = b$8;
70 } else {
71 b$8 = $[1];
compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.expect.md
+6 -6
@@ -19,8 +19,8 @@ function component() {
19
20 ```
21 bb0:
22 - [1] Const mutate t0$10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
23 - [2] Const mutate t1$11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
22 + [1] Const mutate t0$10_@0:TPrimitive = Call mutate makeSomePrimitive$1:TFunction()
23 + [2] Const mutate t1$11_@1:TPrimitive = Call mutate makeSomePrimitive$1:TFunction()
24 [3] Const mutate x$12_@2:TObject = Object { u: read t0$10_@0:TPrimitive, v: read t1$11_@1:TPrimitive }
25 [4] Const mutate u$13:TPrimitive = read x$12_@2.u
26 [5] Const mutate v$14:TPrimitive = read x$12_@2.v
@@ -39,10 +39,10 @@ bb1:
39 function component(
40 ) {
41 scope @0 [1:2] deps=[] out=[$10_@0] {
42 - [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
42 + [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$1:TFunction()
43 }
44 scope @1 [2:3] deps=[] out=[$11_@1] {
45 - [2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
45 + [2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$1:TFunction()
46 }
47 scope @2 [3:4] deps=[read $10_@0:TPrimitive, read $11_@1:TPrimitive] out=[x$12_@2] {
48 [3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
@@ -66,7 +66,7 @@ function component$0() {
66 const $ = React.useMemoCache();
67 let t0$10;
68 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
69 - t0$10 = makeSomePrimitive$2();
69 + t0$10 = makeSomePrimitive$1();
70 $[0] = t0$10;
71 } else {
72 t0$10 = $[0];
@@ -75,7 +75,7 @@ function component$0() {
75 let t1$11;
76
77 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
78 - t1$11 = makeSomePrimitive$2();
78 + t1$11 = makeSomePrimitive$1();
79 $[1] = t1$11;
80 } else {
81 t1$11 = $[1];
compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.expect.md
+3 -3
@@ -22,7 +22,7 @@ function component() {
22
23 ```
24 bb0:
25 - [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$2:TFunction()
25 + [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$1:TFunction()
26 [2] Binary read p$7_@0:TPrimitive + read p$7_@0:TPrimitive
27 [3] Const mutate o$8_@1:TObject = Object { }
28 [4] Const mutate x$9_@2:TObject[4:8] = Object { }
@@ -39,7 +39,7 @@ bb0:
39 function component(
40 ) {
41 scope @0 [1:2] deps=[] out=[p$7_@0] {
42 - [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$2:TFunction()
42 + [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$1:TFunction()
43 }
44 [2] Binary read p$7_@0:TPrimitive + read p$7_@0:TPrimitive
45 scope @1 [3:4] deps=[] out=[o$8_@1] {
@@ -64,7 +64,7 @@ function component$0() {
64 const $ = React.useMemoCache();
65 let p$7;
66 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
67 - p$7 = makePrimitive$2();
67 + p$7 = makePrimitive$1();
68 $[0] = p$7;
69 } else {
70 p$7 = $[0];
compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.expect.md
+9 -9
@@ -18,8 +18,8 @@ function component() {
18
19 ```
20 bb0:
21 - [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
22 - [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
21 + [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$1:TFunction()
22 + [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$1:TFunction()
23 [3] Const mutate $9:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
24 [4] If (read $9:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
25 bb2:
@@ -28,7 +28,7 @@ bb2:
28 [6] Goto bb1
29 bb1:
30 predecessor blocks: bb2 bb0
31 - [7] Const mutate z$12_@3 = Call mutate foo$2:TFunction()
31 + [7] Const mutate z$12_@3 = Call mutate foo$1:TFunction()
32 [8] Return
33 ```
34
@@ -38,16 +38,16 @@ bb1:
38 function component(
39 ) {
40 scope @0 [1:2] deps=[] out=[x$7_@0] {
41 - [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
41 + [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$1:TFunction()
42 }
43 scope @1 [2:3] deps=[] out=[y$8_@1] {
44 - [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
44 + [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$1:TFunction()
45 }
46 [3] Const mutate $9:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
47 if (read $9:TPrimitive) {
48 [5] Const mutate z$10_@2:TObject = Object { }
49 }
50 - [7] Const mutate z$12_@3 = Call mutate foo$2:TFunction()
50 + [7] Const mutate z$12_@3 = Call mutate foo$1:TFunction()
51 return
52 }
53
@@ -60,7 +60,7 @@ function component$0() {
60 const $ = React.useMemoCache();
61 let x$7;
62 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
63 - x$7 = foo$2();
63 + x$7 = foo$1();
64 $[0] = x$7;
65 } else {
66 x$7 = $[0];
@@ -69,7 +69,7 @@ function component$0() {
69 let y$8;
70
71 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
72 - y$8 = foo$2();
72 + y$8 = foo$1();
73 $[1] = y$8;
74 } else {
75 y$8 = $[1];
@@ -79,7 +79,7 @@ function component$0() {
79 const z$10 = {};
80 }
81
82 - const z$12 = foo$2();
82 + const z$12 = foo$1();
83 }
84
85 ```