@samitouri / QOS-React-2 / commits / ff29264050

[typer] Remove type inference of fields

Given that our type inference needs to be very conservative, there's not a lot of benefit to having such fine grained type inference. In the future, we can use type information from flow/ts for inference.

Sathya Gunasekaran committed Dec 21, 2022 at 21:13 UTC ff29264050bba9ae823b7fc41eccf88dae28a28b
9 files changed +93 -255
compiler/forget/src/HIR/HIR.ts
+2 -30
@@ -451,15 +451,13 @@ export type Type =
451 | PrimitiveType
452 | FunctionType
453 | ObjectType
454 - | PropType
454 | PolyType
455 | TypeVar;
456 export type PrimitiveType = { kind: "Primitive" };
457 export type FunctionType = {
458 kind: "Function";
459 };
461 -export type ObjectType = { kind: "Object"; properties: Map<string, Type> };
462 -export type PropType = { kind: "Prop"; objectType: Type; name: string };
460 +export type ObjectType = { kind: "Object" };
461 export type TypeVar = {
462 kind: "Type";
463 id: TypeId;
@@ -497,7 +495,6 @@ export function typeEquals(tA: Type, tB: Type): boolean {
495 typeVarEquals(tA, tB) ||
496 funcTypeEquals(tA, tB) ||
497 objectTypeEquals(tA, tB) ||
500 - propTypeEquals(tA, tB) ||
498 primitiveTypeEquals(tA, tB) ||
499 polyTypeEquals(tA, tB)
500 );
@@ -519,32 +516,7 @@ function polyTypeEquals(tA: Type, tB: Type): boolean {
516 }
517
518 function objectTypeEquals(tA: Type, tB: Type): boolean {
522 - if (tA.kind === "Object" && tB.kind === "Object") {
523 - if (tA.properties.size !== tB.properties.size) {
524 - return false;
525 - }
526 -
527 - for (const key of tA.properties.keys()) {
528 - if (!typeEquals(tA.properties.get(key)!, tB.properties.get(key)!)) {
529 - return false;
530 - }
531 - }
532 -
533 - return true;
534 - }
535 -
536 - return false;
537 -}
538 -
539 -function propTypeEquals(tA: Type, tB: Type): boolean {
540 - if (tA.kind === "Prop" && tB.kind === "Prop") {
541 - if (tA.name !== tB.name) {
542 - return false;
543 - }
544 - return objectTypeEquals(tA.objectType, tB.objectType);
545 - }
546 -
547 - return false;
519 + return tA.kind === "Object" && tB.kind === "Object";
520 }
521
522 function funcTypeEquals(tA: Type, tB: Type): boolean {
compiler/forget/src/HIR/InferTypes.ts
+23 -157
@@ -3,10 +3,7 @@ import invariant from "invariant";
3 import {
4 HIRFunction,
5 Instruction,
6 - LValue,
7 - makeType,
6 Place,
9 - PropType,
7 Type,
8 typeEquals,
9 TypeId,
@@ -85,130 +82,60 @@ function generateTypeEquation(
82 unifier: Unifier
83 ): Array<TypeEquation> {
84 const equations: Array<TypeEquation> = [];
85 +
86 + function add(left: Type | null, right: Type | null) {
87 + if (left === null || right === null) return;
88 + equations.push({
89 + left,
90 + right,
91 + });
92 + }
93 +
94 const { lvalue, value } = instr;
89 - const left: Type | null = assignTypeForLvalue(lvalue, equations, unifier);
95 + const left = assignType(lvalue?.place);
96
97 switch (value.kind) {
98 case "Primitive": {
93 - if (left !== null) {
94 - equations.push({
95 - left,
96 - right: { kind: "Primitive" },
97 - });
98 - }
99 + add(left, { kind: "Primitive" });
100 break;
101 }
102
103 case "Identifier": {
103 - if (left !== null) {
104 - let right: Type = assignTypeForPlace(value, equations);
105 - equations.push({
106 - left,
107 - right,
108 - });
109 - }
110 -
104 + add(left, assignType(value));
105 break;
106 }
107
108 case "BinaryExpression": {
109 if (isPrimitiveBinaryOp(value.operator)) {
116 - equations.push({
117 - left: value.left.identifier.type,
118 - right: { kind: "Primitive" },
119 - });
120 - equations.push({
121 - left: value.right.identifier.type,
122 - right: { kind: "Primitive" },
123 - });
110 + add(assignType(value.left), { kind: "Primitive" });
111 + add(assignType(value.right), { kind: "Primitive" });
112 }
125 -
126 - if (left !== null) {
127 - equations.push({
128 - left,
129 - right: { kind: "Primitive" },
130 - });
131 - }
132 -
113 + add(left, { kind: "Primitive" });
114 break;
115 }
116
117 case "CallExpression": {
137 - const argTypes = value.args.map((a) => a.identifier.type);
138 -
139 - // TODO(gsn): Handle method calls separately
140 - if (value.callee.memberPath !== null) {
141 - break;
142 - }
143 -
144 - equations.push({
145 - left: value.callee.identifier.type,
146 - right: { kind: "Function" },
147 - });
148 -
118 + add(assignType(value.callee), { kind: "Function" });
119 break;
120 }
121
122 case "ObjectExpression": {
123 invariant(left !== null, "invald object expression");
154 - const properties = new Map(
155 - [...(value.properties?.entries() ?? [])].map(([prop, place]) => [
156 - prop,
157 - place.identifier.type,
158 - ])
159 - );
160 -
161 - equations.push({
162 - left,
163 - right: {
164 - kind: "Object",
165 - properties,
166 - },
167 - });
124 + add(left, { kind: "Object" });
125 break;
126 }
127 }
128 return equations;
129 }
130
174 -function assignTypeForPlace(
175 - value: Place,
176 - equations: Array<TypeEquation>
177 -): Type {
178 - if (value.memberPath === null) {
179 - return value.identifier.type;
180 - }
181 -
182 - if (value.memberPath.length > 1) {
183 - // TODO(gsn): Lower nested memberPaths in HIR
184 - return makeType();
131 +function assignType(place: Place | undefined): Type | null {
132 + // We type only top level identifiers. Typing objects is not very useful
133 + // when we have to be so conservative.
134 + if (place?.memberPath !== null) {
135 + return null;
136 }
137
187 - const propName = value.memberPath[0];
188 - const propType = makeType();
189 - equations.push({
190 - left: propType,
191 - right: {
192 - kind: "Prop",
193 - objectType: value.identifier.type,
194 - name: propName,
195 - },
196 - });
197 -
198 - return propType;
199 -}
200 -
201 -function assignTypeForLvalue(
202 - lvalue: LValue | null,
203 - equations: Array<TypeEquation>,
204 - unifier: Unifier
205 -): Type | null {
206 - if (lvalue === null) return null;
207 -
208 - return (
209 - unifier.generalize(lvalue.place.identifier.type, lvalue.place.memberPath) ??
210 - assignTypeForPlace(lvalue.place, equations)
211 - );
138 + return place.identifier.type;
139 }
140
141 type Substitution = Map<TypeId, Type>;
@@ -242,11 +169,6 @@ class Unifier {
169 return;
170 }
171
245 - if (type.kind === "Prop") {
246 - this.bindToProp(v, type);
247 - return;
248 - }
249 -
172 if (this.occursCheck(v, type)) {
173 throw new Error("cycle detected");
174 }
@@ -254,26 +176,6 @@ class Unifier {
176 this.substitutions.set(v.id, type);
177 }
178
257 - bindToProp(type: TypeVar, prop: PropType) {
258 - let object = prop.objectType;
259 -
260 - if (object.kind === "Type" && this.substitutions.has(object.id)) {
261 - object = this.substitutions.get(object.id)!;
262 - }
263 -
264 - if (object.kind === "Object") {
265 - if (!object.properties.has(prop.name)) {
266 - object.properties.set(prop.name, type);
267 - return;
268 - }
269 -
270 - this.unify(object.properties.get(prop.name)!, type);
271 - return;
272 - }
273 -
274 - this.substitutions.set(type.id, prop);
275 - }
276 -
179 occursCheck(v: TypeVar, type: Type): boolean {
180 if (typeEquals(v, type)) return true;
181
@@ -281,22 +183,10 @@ class Unifier {
183 return this.occursCheck(v, this.substitutions.get(type.id)!);
184 }
185
284 - if (type.kind === "Object") {
285 - return [...type.properties.values()].some((p) => this.occursCheck(v, p));
286 - }
287 -
288 - if (type.kind === "Prop") {
289 - return this.occursCheck(v, type.objectType);
290 - }
291 -
186 return false;
187 }
188
189 get(type: Type): Type {
296 - if (type.kind === "Primitive") {
297 - return type;
298 - }
299 -
190 if (type.kind === "Type") {
191 if (this.substitutions.has(type.id)) {
192 return this.get(this.substitutions.get(type.id)!);
@@ -307,28 +197,4 @@ class Unifier {
197
198 return type;
199 }
310 -
311 - generalize(objectType: Type, name: Array<string> | null): Type | null {
312 - if (objectType.kind === "Type" && this.substitutions.has(objectType.id)) {
313 - objectType = this.substitutions.get(objectType.id)!;
314 - }
315 -
316 - if (
317 - name !== null &&
318 - objectType.kind === "Object" &&
319 - objectType.properties.has(name[0])
320 - ) {
321 - let type = objectType.properties.get(name[0])!;
322 - if (type.kind === "Poly") {
323 - return type;
324 - }
325 -
326 - type = { kind: "Poly" };
327 -
328 - objectType.properties.set(name[0], type);
329 - return type;
330 - }
331 -
332 - return null;
333 - }
200 }
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+18 -18
@@ -35,12 +35,12 @@ function Component(props) {
35
36 ```
37 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 []
38 + [1] Const mutate items$30 = read props$29.items
39 + [2] Const mutate maxItems$31 = read props$29.maxItems
40 + [3] Const mutate renderedItems$32_@0[3:33] = Array []
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$7.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)
44 [7] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
45 bb3:
46 predecessor blocks: bb0
@@ -92,15 +92,15 @@ bb4:
92 [32] Goto bb1
93 bb2:
94 predecessor blocks: bb6 bb1
95 - [33] Const mutate count$66:TProp = read renderedItems$32_@0.length
95 + [33] Const mutate count$66 = read renderedItems$32_@0.length
96 [34] Const mutate $67:TPrimitive = "div"
97 [35] Const mutate $68 = "\n "
98 [36] Const mutate $69:TPrimitive = "h1"
99 [37] Const mutate $70 = " Items"
100 - [38] Const mutate t7$71_@5 = JSX <read $69:TPrimitive>{freeze count$66:TProp}{read $70}</read $69:TPrimitive>
100 + [38] Const mutate t7$71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70}</read $69:TPrimitive>
101 [39] Const mutate $72 = "\n "
102 [40] Const mutate $73 = "\n "
103 - [41] Const mutate t10$74_@6 = JSX <read $67:TPrimitive>{read $68}{read t7$71_@5}{read $72}{freeze renderedItems$32_@0:TPrimitive}{read $73}</read $67:TPrimitive>
103 + [41] Const mutate t10$74_@6 = JSX <read $67:TPrimitive>{read $68}{read t7$71_@5}{read $72}{freeze renderedItems$32_@0}{read $73}</read $67:TPrimitive>
104 [42] Return read t10$74_@6
105 ```
106
@@ -110,14 +110,14 @@ bb2:
110 function Component(
111 props,
112 ) {
113 - [1] Const mutate items$30:TProp = read props$29.items
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 []
113 + [1] Const mutate items$30 = read props$29.items
114 + [2] Const mutate maxItems$31 = read props$29.maxItems
115 + scope @0 [3:33] deps=[read maxItems$31, read items$30.length, read items$30] out=[renderedItems$32_@0] {
116 + [3] Const mutate renderedItems$32_@0[3:33] = Array []
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$7.max(read $34:TPrimitive, read maxItems$31:TProp)
119 + scope @2 [6:7] deps=[read maxItems$31] out=[max$35_@2] {
120 + [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$7.max(read $34:TPrimitive, read maxItems$31)
121 }
122 for (
123 [8] Let mutate i$36_@0:TPrimitive[3:33] = 0
@@ -153,18 +153,18 @@ function Component(
153 }
154 }
155 }
156 - [33] Const mutate count$66:TProp = read renderedItems$32_@0.length
156 + [33] Const mutate count$66 = read renderedItems$32_@0.length
157 [34] Const mutate $67:TPrimitive = "div"
158 [35] Const mutate $68 = "\n "
159 [36] Const mutate $69:TPrimitive = "h1"
160 [37] Const mutate $70 = " Items"
161 - scope @5 [38:39] deps=[freeze count$66:TProp] out=[$71_@5] {
162 - [38] Const mutate $71_@5 = JSX <read $69:TPrimitive>{freeze count$66:TProp}{read $70}</read $69:TPrimitive>
161 + scope @5 [38:39] deps=[freeze count$66] out=[$71_@5] {
162 + [38] Const mutate $71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70}</read $69:TPrimitive>
163 }
164 [39] Const mutate $72 = "\n "
165 [40] Const mutate $73 = "\n "
166 - scope @6 [41:42] deps=[read $71_@5, freeze renderedItems$32_@0:TPrimitive] out=[$74_@6] {
167 - [41] Const mutate $74_@6 = JSX <read $67:TPrimitive>{read $68}{read $71_@5}{read $72}{freeze renderedItems$32_@0:TPrimitive}{read $73}</read $67:TPrimitive>
166 + scope @6 [41:42] deps=[read $71_@5, freeze renderedItems$32_@0] out=[$74_@6] {
167 + [41] Const mutate $74_@6 = JSX <read $67:TPrimitive>{read $68}{read $71_@5}{read $72}{freeze renderedItems$32_@0}{read $73}</read $67:TPrimitive>
168 }
169 return read $74_@6
170 }
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+11 -11
@@ -26,15 +26,15 @@ function call(x) {}
26
27 ```
28 bb0:
29 - [1] Const mutate cond$8:TProp = read props$7.cond
30 - [2] Const mutate x$9:TProp = read props$7.x
29 + [1] Const mutate cond$8 = read props$7.cond
30 + [2] Const mutate x$9 = read props$7.x
31 [3] Const mutate a$10:TPrimitive = undefined
32 [4] Let mutate a$14_@0[4:9] = undefined
33 - [4] If (read cond$8:TProp) then:bb2 else:bb3 fallthrough=bb1
33 + [4] If (read cond$8) then:bb2 else:bb3 fallthrough=bb1
34 bb2:
35 predecessor blocks: bb0
36 - [5] Const mutate a$11:TProp = read x$9:TProp
37 - [6] Reassign mutate a$14_@0[4:9] = read a$11:TProp
36 + [5] Const mutate a$11 = read x$9
37 + [6] Reassign mutate a$14_@0[4:9] = read a$11
38 [6] Goto bb1
39 bb3:
40 predecessor blocks: bb0
@@ -55,14 +55,14 @@ bb1:
55 function Component(
56 props,
57 ) {
58 - [1] Const mutate cond$8:TProp = read props$7.cond
59 - [2] Const mutate x$9:TProp = read props$7.x
58 + [1] Const mutate cond$8 = read props$7.cond
59 + [2] Const mutate x$9 = read props$7.x
60 [3] Const mutate a$10:TPrimitive = undefined
61 - scope @0 [4:9] deps=[read cond$8:TProp, read x$9:TProp] out=[a$14_@0] {
61 + scope @0 [4:9] deps=[read cond$8, read x$9] out=[a$14_@0] {
62 [4] Let mutate a$14_@0[4:9] = undefined
63 - if (read cond$8:TProp) {
64 - [5] Const mutate a$11:TProp = read x$9:TProp
65 - [6] Reassign mutate a$14_@0[4:9] = read a$11:TProp
63 + if (read cond$8) {
64 + [5] Const mutate a$11 = read x$9
65 + [6] Reassign mutate a$14_@0[4:9] = read a$11
66 } else {
67 scope @1 [7:8] deps=[] out=[a$12_@1] {
68 [7] Const mutate a$12_@1 = Array []
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+20 -20
@@ -52,31 +52,31 @@ bb2:
52 Fallthrough: bb1
53 bb8:
54 predecessor blocks: bb2
55 - [7] Const mutate x$11:TProp = read props$6.v0
56 - [8] Reassign mutate x$16_@0[2:18] = read x$11:TProp
55 + [7] Const mutate x$11 = read props$6.v0
56 + [8] Reassign mutate x$16_@0[2:18] = read x$11
57 [8] Goto bb1
58 bb6:
59 predecessor blocks: bb2
60 - [9] Const mutate x$12:TProp = read props$6.v1
61 - [10] Reassign mutate x$16_@0[2:18] = read x$12:TProp
60 + [9] Const mutate x$12 = read props$6.v1
61 + [10] Reassign mutate x$16_@0[2:18] = read x$12
62 [10] Goto bb1
63 bb4:
64 predecessor blocks: bb2
65 - [11] Const mutate x$13:TProp = read props$6.v2
66 - [12] Reassign mutate x$16_@0[2:18] = read x$13:TProp
65 + [11] Const mutate x$13 = read props$6.v2
66 + [12] Reassign mutate x$16_@0[2:18] = read x$13
67 [12] Goto bb1
68 bb10:
69 predecessor blocks: bb0
70 [13] If (read props$6.cond2) then:bb12 else:bb13 fallthrough=bb1
71 bb12:
72 predecessor blocks: bb10
73 - [14] Const mutate x$14:TProp = read props$6.b
74 - [15] Reassign mutate x$16_@0[2:18] = read x$14:TProp
73 + [14] Const mutate x$14 = read props$6.b
74 + [15] Reassign mutate x$16_@0[2:18] = read x$14
75 [15] Goto bb1
76 bb13:
77 predecessor blocks: bb10
78 - [16] Const mutate x$15:TProp = read props$6.c
79 - [17] Reassign mutate x$16_@0[2:18] = read x$15:TProp
78 + [16] Const mutate x$15 = read props$6.c
79 + [17] Reassign mutate x$16_@0[2:18] = read x$15
80 [17] Goto bb1
81 bb1:
82 predecessor blocks: bb8 bb6 bb4 bb12 bb13
@@ -99,29 +99,29 @@ function Component(
99 [5] Const mutate $10:TPrimitive = 0
100 switch (read props$6.test) {
101 case read $10:TPrimitive: {
102 - [7] Const mutate x$11:TProp = read props$6.v0
103 - [8] Reassign mutate x$16_@0[2:18] = read x$11:TProp
102 + [7] Const mutate x$11 = read props$6.v0
103 + [8] Reassign mutate x$16_@0[2:18] = read x$11
104 break bb1
105 }
106 case read $9:TPrimitive: {
107 - [9] Const mutate x$12:TProp = read props$6.v1
108 - [10] Reassign mutate x$16_@0[2:18] = read x$12:TProp
107 + [9] Const mutate x$12 = read props$6.v1
108 + [10] Reassign mutate x$16_@0[2:18] = read x$12
109 break bb1
110 }
111 case read $8:TPrimitive: {
112 }
113 default: {
114 - [11] Const mutate x$13:TProp = read props$6.v2
115 - [12] Reassign mutate x$16_@0[2:18] = read x$13:TProp
114 + [11] Const mutate x$13 = read props$6.v2
115 + [12] Reassign mutate x$16_@0[2:18] = read x$13
116 }
117 }
118 } else {
119 if (read props$6.cond2) {
120 - [14] Const mutate x$14:TProp = read props$6.b
121 - [15] Reassign mutate x$16_@0[2:18] = read x$14:TProp
120 + [14] Const mutate x$14 = read props$6.b
121 + [15] Reassign mutate x$16_@0[2:18] = read x$14
122 } else {
123 - [16] Const mutate x$15:TProp = read props$6.c
124 - [17] Reassign mutate x$16_@0[2:18] = read x$15:TProp
123 + [16] Const mutate x$15 = read props$6.c
124 + [17] Reassign mutate x$16_@0[2:18] = read x$15
125 }
126 }
127 }
compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md
+2 -2
@@ -15,7 +15,7 @@ function component() {
15 bb0:
16 [1] Const mutate $4:TPrimitive = 1
17 [2] Const mutate x$5_@0:TObject = Object { t: read $4:TPrimitive }
18 - [3] Const mutate p$6:TPrimitive = read x$5_@0.t
18 + [3] Const mutate p$6 = read x$5_@0.t
19 [4] Return
20 ```
21
@@ -28,7 +28,7 @@ function component(
28 scope @0 [2:3] deps=[] out=[x$5_@0] {
29 [2] Const mutate x$5_@0:TObject = Object { t: read $4:TPrimitive }
30 }
31 - [3] Const mutate p$6:TPrimitive = read x$5_@0.t
31 + [3] Const mutate p$6 = read x$5_@0.t
32 return
33 }
34
compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.expect.md
+11 -11
@@ -19,17 +19,17 @@ function component() {
19
20 ```
21 bb0:
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 }
22 + [1] Const mutate t0$10_@0 = Call mutate makeSomePrimitive$1:TFunction()
23 + [2] Const mutate t1$11_@1 = Call mutate makeSomePrimitive$1:TFunction()
24 + [3] Const mutate x$12_@2:TObject = Object { u: read t0$10_@0, v: read t1$11_@1 }
25 [4] Const mutate u$13:TPrimitive = read x$12_@2.u
26 [5] Const mutate v$14:TPrimitive = read x$12_@2.v
27 [6] Const mutate $15:TPrimitive = Binary read u$13:TPrimitive > read v$14:TPrimitive
28 [7] If (read $15:TPrimitive) then:bb1 else:bb1 fallthrough=bb1
29 bb1:
30 predecessor blocks: bb0
31 - [8] Const mutate y$16:TPrimitive = read x$12_@2.u
32 - [9] Const mutate z$17:TPrimitive = read x$12_@2.v
31 + [8] Const mutate y$16 = read x$12_@2.u
32 + [9] Const mutate z$17 = read x$12_@2.v
33 [10] Return
34 ```
35
@@ -39,21 +39,21 @@ bb1:
39 function component(
40 ) {
41 scope @0 [1:2] deps=[] out=[$10_@0] {
42 - [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$1:TFunction()
42 + [1] Const mutate $10_@0 = 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$1:TFunction()
45 + [2] Const mutate $11_@1 = 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 }
47 + scope @2 [3:4] deps=[read $10_@0, read $11_@1] out=[x$12_@2] {
48 + [3] Const mutate x$12_@2:TObject = Object { u: read $10_@0, v: read $11_@1 }
49 }
50 [4] Const mutate u$13:TPrimitive = read x$12_@2.u
51 [5] Const mutate v$14:TPrimitive = read x$12_@2.v
52 [6] Const mutate $15:TPrimitive = Binary read u$13:TPrimitive > read v$14:TPrimitive
53 if (read $15:TPrimitive) {
54 }
55 - [8] Const mutate y$16:TPrimitive = read x$12_@2.u
56 - [9] Const mutate z$17:TPrimitive = read x$12_@2.v
55 + [8] Const mutate y$16 = read x$12_@2.u
56 + [9] Const mutate z$17 = read x$12_@2.v
57 return
58 }
59
compiler/forget/src/__tests__/fixtures/hir/type-test-field-store.expect.md
+2 -2
@@ -18,7 +18,7 @@ bb0:
18 [1] Const mutate x$4_@0:TObject[1:4] = Object { }
19 [2] Const mutate q$5_@1:TObject = Object { }
20 [3] Reassign store x$4_@0.t[1:4] = read q$5_@1:TObject
21 - [4] Const mutate z$6:TObject = read x$4_@0.t
21 + [4] Const mutate z$6 = read x$4_@0.t
22 [5] Return
23 ```
24
@@ -34,7 +34,7 @@ function component(
34 }
35 [3] Reassign store x$4_@0.t[1:4] = read q$5_@1:TObject
36 }
37 - [4] Const mutate z$6:TObject = read x$4_@0.t
37 + [4] Const mutate z$6 = read x$4_@0.t
38 return
39 }
40
compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.expect.md
+4 -4
@@ -27,9 +27,9 @@ bb0:
27 [3] Const mutate o$8_@1:TObject = Object { }
28 [4] Const mutate x$9_@2:TObject[4:8] = Object { }
29 [5] Reassign store x$9_@2.t[4:8] = read p$7_@0:TPrimitive
30 - [6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
30 + [6] Const mutate z$10_@2[4:8] = read x$9_@2.t
31 [7] Reassign store x$9_@2.t[4:8] = read o$8_@1:TObject
32 - [8] Const mutate y$11:TPoly = read x$9_@2.t
32 + [8] Const mutate y$11 = read x$9_@2.t
33 [9] Return
34 ```
35
@@ -48,10 +48,10 @@ function component(
48 scope @2 [4:8] deps=[read p$7_@0:TPrimitive, read o$8_@1:TObject] out=[x$9_@2] {
49 [4] Const mutate x$9_@2:TObject[4:8] = Object { }
50 [5] Reassign store x$9_@2.t[4:8] = read p$7_@0:TPrimitive
51 - [6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
51 + [6] Const mutate z$10_@2[4:8] = read x$9_@2.t
52 [7] Reassign store x$9_@2.t[4:8] = read o$8_@1:TObject
53 }
54 - [8] Const mutate y$11:TPoly = read x$9_@2.t
54 + [8] Const mutate y$11 = read x$9_@2.t
55 return
56 }
57