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

[typer] Be more conservative with function type inference

It's not safe to infer types of arguments and return values because Javascript is so polymorphic. Instead just infer the type of the callee for non methods. Interestingly, even this is not conservative enough for JavaScript because Proxy can also be callable. But I think for our use cases we will treat Proxy and Functions similarly (they're all just objects) so it's ok.

Sathya Gunasekaran committed Dec 20, 2022 at 13:38 UTC 2c3e572566daebda9581074984ef3fa29ce21e5d
27 files changed +201 -246
compiler/forget/src/HIR/HIR.ts
+1 -20
@@ -455,8 +455,6 @@ export type Type =
455 export type PrimitiveType = { kind: "Primitive" };
456 export type FunctionType = {
457 kind: "Function";
458 - argTypes: Array<Type>;
459 - returnType: Type;
458 };
459 export type ObjectType = { kind: "Object"; properties: Map<string, Type> };
460 export type PropType = { kind: "Prop"; objectType: Type; name: string };
@@ -531,22 +529,5 @@ function propTypeEquals(tA: Type, tB: Type): boolean {
529 }
530
531 function funcTypeEquals(tA: Type, tB: Type): boolean {
534 - if (tA.kind === "Function" && tB.kind === "Function") {
535 - if (tA.returnType !== tB.returnType) {
536 - return false;
537 - }
538 -
539 - if (tA.argTypes.length !== tB.argTypes.length) {
540 - return false;
541 - }
542 -
543 - for (let i = 0; i < tA.argTypes.length; i++) {
544 - if (!typeVarEquals(tA.argTypes[i], tB.argTypes[i])) {
545 - return false;
546 - }
547 - }
548 -
549 - return true;
550 - }
551 - return false;
532 + return tA.kind === "Function" && tB.kind === "Function";
533 }
compiler/forget/src/HIR/InferTypes.ts
+6 -32
@@ -132,20 +132,17 @@ function generateTypeEquation(
132 break;
133 }
134
135 - // TODO(gsn): This is potentially unsafe if we're modeling JavaScript as
136 - // these should be PolyTypes. Modeling PolyTypes seems overkill for Forget
137 - // as we're super conservative anyway. Should we not model function
138 - // application?
135 case "CallExpression": {
136 const argTypes = value.args.map((a) => a.identifier.type);
137
138 + // TODO(gsn): Handle method calls separately
139 + if (value.callee.memberPath !== null) {
140 + break;
141 + }
142 +
143 equations.push({
144 left: value.callee.identifier.type,
144 - right: {
145 - kind: "Function",
146 - argTypes,
147 - returnType: left ?? makeType(),
148 - },
145 + right: { kind: "Function" },
146 });
147
148 break;
@@ -231,14 +228,6 @@ class Unifier {
228 this.bindVariableTo(tB, tA);
229 return;
230 }
234 -
235 - if (tA.kind === "Function" && tB.kind === "Function") {
236 - const len = Math.min(tA.argTypes.length, tB.argTypes.length);
237 - for (let i = 0; i < len; i++) {
238 - this.unify(tA.argTypes[i], tB.argTypes[i]);
239 - }
240 - this.unify(tA.returnType, tB.returnType);
241 - }
231 }
232
233 bindVariableTo(v: TypeVar, type: Type): void {
@@ -291,13 +280,6 @@ class Unifier {
280 return this.occursCheck(v, this.substitutions.get(type.name)!);
281 }
282
294 - if (type.kind === "Function") {
295 - return (
296 - this.occursCheck(v, type.returnType) ||
297 - type.argTypes.some((a) => this.occursCheck(v, a))
298 - );
299 - }
300 -
283 if (type.kind === "Object") {
284 return [...type.properties.values()].some((p) => this.occursCheck(v, p));
285 }
@@ -322,14 +304,6 @@ class Unifier {
304 }
305 }
306
325 - if (type.kind === "Function") {
326 - return {
327 - kind: "Function",
328 - argTypes: type.argTypes.map((a) => this.get(a)),
329 - returnType: this.get(type.returnType),
330 - };
331 - }
332 -
307 return type;
308 }
309
compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md
+4 -4
@@ -24,7 +24,7 @@ function Component(props) {
24
25 ```
26 bb0:
27 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
27 + [1] Const mutate a$4_@0[1:7] = Array []
28 [2] Call mutate a$4_@0.push(read props$3.a)
29 [3] If (read props$3.b) then:bb1 else:bb2 fallthrough=bb2
30 bb2:
@@ -34,7 +34,7 @@ bb2:
34 bb1:
35 predecessor blocks: bb0 bb2
36 [6] Call mutate a$4_@0.push(read props$3.d)
37 - [7] Return freeze a$4_@0:TFunction
37 + [7] Return freeze a$4_@0
38 ```
39
40 ## Reactive Scopes
@@ -44,11 +44,11 @@ function Component(
44 props,
45 ) {
46 scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.d, read props$3.c] out=[] {
47 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
47 + [1] Const mutate a$4_@0[1:7] = Array []
48 [2] Call mutate a$4_@0.push(read props$3.a)
49 if (read props$3.b) {
50 [6] Call mutate a$4_@0.push(read props$3.d)
51 - return freeze a$4_@0:TFunction
51 + return freeze a$4_@0
52 }
53 [4] Call mutate a$4_@0.push(read props$3.c)
54 }
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+10 -10
@@ -42,14 +42,14 @@ function foo$0() {}
42
43 ```
44 bb0:
45 - [1] Const mutate a$10_@0:TObject[1:7] = Array []
45 + [1] Const mutate a$10_@0[1:7] = Array []
46 [2] Const mutate b$11_@0:TObject[1:7] = Object { }
47 - [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
47 + [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
48 [4] Const mutate $12:TPrimitive = "div"
49 - [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0:TObject} ></read $12:TPrimitive>
49 + [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
50 [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
51 [7] Const mutate $14:TPrimitive = "div"
52 - [8] Const mutate t5$15_@2 = JSX <read $14:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
52 + [8] Const mutate t5$15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
53 [9] Return read t5$15_@2
54 ```
55
@@ -60,18 +60,18 @@ function Component(
60 props,
61 ) {
62 scope @0 [1:7] deps=[] out=[a$10_@0, b$11_@0] {
63 - [1] Const mutate a$10_@0:TObject[1:7] = Array []
63 + [1] Const mutate a$10_@0[1:7] = Array []
64 [2] Const mutate b$11_@0:TObject[1:7] = Object { }
65 - [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
65 + [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
66 [4] Const mutate $12:TPrimitive = "div"
67 - scope @1 [5:6] deps=[freeze a$10_@0:TObject] out=[] {
68 - [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0:TObject} ></read $12:TPrimitive>
67 + scope @1 [5:6] deps=[freeze a$10_@0] out=[] {
68 + [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
69 }
70 [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
71 }
72 [7] Const mutate $14:TPrimitive = "div"
73 - scope @2 [8:9] deps=[read a$10_@0:TObject, freeze b$11_@0:TObject] out=[$15_@2] {
74 - [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
73 + scope @2 [8:9] deps=[read a$10_@0, freeze b$11_@0:TObject] out=[$15_@2] {
74 + [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
75 }
76 return read $15_@2
77 }
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+7 -7
@@ -37,8 +37,8 @@ function Component(props) {
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:TFunction[3:33] = Array []
41 - [4] Const mutate seen$33_@0:TFunction[3:33] = New mutate Set$6()
40 + [3] Const mutate renderedItems$32_@0:TPrimitive[3:33] = Array []
41 + [4] Const mutate seen$33_@0[3:33] = New mutate Set$6()
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)
44 [7] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
@@ -98,7 +98,7 @@ bb2:
98 [38] Const mutate t7$71_@4 = JSX <read $69:TPrimitive>{freeze count$66:TProp}{read $70}</read $69:TPrimitive>
99 [39] Const mutate $72 = "\n "
100 [40] Const mutate $73 = "\n "
101 - [41] Const mutate t10$74_@5 = JSX <read $67:TPrimitive>{read $68}{read t7$71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73}</read $67:TPrimitive>
101 + [41] Const mutate t10$74_@5 = JSX <read $67:TPrimitive>{read $68}{read t7$71_@4}{read $72}{freeze renderedItems$32_@0:TPrimitive}{read $73}</read $67:TPrimitive>
102 [42] Return read t10$74_@5
103 ```
104
@@ -111,8 +111,8 @@ function Component(
111 [1] Const mutate items$30:TProp = read props$29.items
112 [2] Const mutate maxItems$31:TProp = read props$29.maxItems
113 scope @0 [3:33] deps=[read maxItems$31:TProp, read items$30.length, read items$30] out=[renderedItems$32_@0] {
114 - [3] Const mutate renderedItems$32_@0:TFunction[3:33] = Array []
115 - [4] Const mutate seen$33_@0:TFunction[3:33] = New mutate Set$6()
114 + [3] Const mutate renderedItems$32_@0:TPrimitive[3:33] = Array []
115 + [4] Const mutate seen$33_@0[3:33] = New mutate Set$6()
116 [5] Const mutate $34:TPrimitive = 0
117 scope @2 [6:7] deps=[read maxItems$31:TProp] out=[max$35_@2] {
118 [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp)
@@ -159,8 +159,8 @@ function Component(
159 }
160 [39] Const mutate $72 = "\n "
161 [40] Const mutate $73 = "\n "
162 - scope @5 [41:42] deps=[read $71_@4, freeze renderedItems$32_@0:TFunction] out=[$74_@5] {
163 - [41] Const mutate $74_@5 = JSX <read $67:TPrimitive>{read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73}</read $67:TPrimitive>
162 + scope @5 [41:42] deps=[read $71_@4, freeze renderedItems$32_@0:TPrimitive] out=[$74_@5] {
163 + [41] Const mutate $74_@5 = JSX <read $67:TPrimitive>{read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TPrimitive}{read $73}</read $67:TPrimitive>
164 }
165 return read $74_@5
166 }
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+22 -22
@@ -78,7 +78,7 @@ function Component(props) {
78
79 ```
80 bb0:
81 - [1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
81 + [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
82 [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
83 [3] If (read props$4.b) then:bb2 else:bb1 fallthrough=bb1
84 bb2:
@@ -88,7 +88,7 @@ bb2:
88 bb1:
89 predecessor blocks: bb0
90 [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
91 - [7] Return freeze a_DEBUG$5_@0:TFunction
91 + [7] Return freeze a_DEBUG$5_@0
92 ```
93
94 ## Reactive Scopes
@@ -98,7 +98,7 @@ function Component(
98 props,
99 ) {
100 scope @0 [1:7] deps=[read props$4.a, read props$4.b, read props$4.d] out=[a_DEBUG$5_@0] {
101 - [1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
101 + [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
102 [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
103 if (read props$4.b) {
104 [4] Const mutate $6:TPrimitive = null
@@ -106,7 +106,7 @@ function Component(
106 }
107 [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
108 }
109 - return freeze a_DEBUG$5_@0:TFunction
109 + return freeze a_DEBUG$5_@0
110 }
111
112 ```
@@ -145,7 +145,7 @@ function Component$0(props$4) {
145
146 ```
147 bb0:
148 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
148 + [1] Const mutate a$4_@0[1:7] = Array []
149 [2] Call mutate a$4_@0.push(read props$3.a)
150 [3] If (read props$3.b) then:bb2 else:bb1 fallthrough=bb1
151 bb2:
@@ -155,7 +155,7 @@ bb2:
155 bb1:
156 predecessor blocks: bb2 bb0
157 [6] Call mutate a$4_@0.push(read props$3.d)
158 - [7] Return freeze a$4_@0:TFunction
158 + [7] Return freeze a$4_@0
159 ```
160
161 ## Reactive Scopes
@@ -165,14 +165,14 @@ function Component(
165 props,
166 ) {
167 scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.c, read props$3.d] out=[a$4_@0] {
168 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
168 + [1] Const mutate a$4_@0[1:7] = Array []
169 [2] Call mutate a$4_@0.push(read props$3.a)
170 if (read props$3.b) {
171 [4] Call mutate a$4_@0.push(read props$3.c)
172 }
173 [6] Call mutate a$4_@0.push(read props$3.d)
174 }
175 - return freeze a$4_@0:TFunction
175 + return freeze a$4_@0
176 }
177
178 ```
@@ -213,7 +213,7 @@ function Component$0(props$3) {
213
214 ```
215 bb0:
216 - [1] Const mutate a$5_@0:TFunction[1:8] = Array []
216 + [1] Const mutate a$5_@0[1:8] = Array []
217 [2] Call mutate a$5_@0.push(read props$4.a)
218 [3] If (read props$4.b) then:bb2 else:bb1 fallthrough=bb1
219 bb2:
@@ -224,7 +224,7 @@ bb2:
224 bb1:
225 predecessor blocks: bb0
226 [7] Call mutate a$5_@0.push(read props$4.d)
227 - [8] Return freeze a$5_@0:TFunction
227 + [8] Return freeze a$5_@0
228 ```
229
230 ## Reactive Scopes
@@ -234,7 +234,7 @@ function Component(
234 props,
235 ) {
236 scope @0 [1:8] deps=[read props$4.a, read props$4.b, read props$4.c, read props$4.d] out=[a$5_@0] {
237 - [1] Const mutate a$5_@0:TFunction[1:8] = Array []
237 + [1] Const mutate a$5_@0[1:8] = Array []
238 [2] Call mutate a$5_@0.push(read props$4.a)
239 if (read props$4.b) {
240 [4] Call mutate a$5_@0.push(read props$4.c)
@@ -243,7 +243,7 @@ function Component(
243 }
244 [7] Call mutate a$5_@0.push(read props$4.d)
245 }
246 - return freeze a$5_@0:TFunction
246 + return freeze a$5_@0
247 }
248
249 ```
@@ -285,17 +285,17 @@ function Component$0(props$4) {
285
286 ```
287 bb0:
288 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
288 + [1] Const mutate a$4_@0[1:7] = Array []
289 [2] Call mutate a$4_@0.push(read props$3.a)
290 [3] If (read props$3.b) then:bb2 else:bb1 fallthrough=bb1
291 bb2:
292 predecessor blocks: bb0
293 [4] Call mutate a$4_@0.push(read props$3.c)
294 - [5] Return freeze a$4_@0:TFunction
294 + [5] Return freeze a$4_@0
295 bb1:
296 predecessor blocks: bb0
297 [6] Call mutate a$4_@0.push(read props$3.d)
298 - [7] Return freeze a$4_@0:TFunction
298 + [7] Return freeze a$4_@0
299 ```
300
301 ## Reactive Scopes
@@ -305,15 +305,15 @@ function Component(
305 props,
306 ) {
307 scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.c, read props$3.d] out=[a$4_@0] {
308 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
308 + [1] Const mutate a$4_@0[1:7] = Array []
309 [2] Call mutate a$4_@0.push(read props$3.a)
310 if (read props$3.b) {
311 [4] Call mutate a$4_@0.push(read props$3.c)
312 - return freeze a$4_@0:TFunction
312 + return freeze a$4_@0
313 }
314 [6] Call mutate a$4_@0.push(read props$3.d)
315 }
316 - return freeze a$4_@0:TFunction
316 + return freeze a$4_@0
317 }
318
319 ```
@@ -355,7 +355,7 @@ function Component$0(props$3) {
355
356 ```
357 bb0:
358 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
358 + [1] Const mutate a$4_@0[1:7] = Array []
359 [2] Call mutate a$4_@0.push(read props$3.a)
360 [3] If (read props$3.b) then:bb1 else:bb2 fallthrough=bb2
361 bb2:
@@ -365,7 +365,7 @@ bb2:
365 bb1:
366 predecessor blocks: bb0 bb2
367 [6] Call mutate a$4_@0.push(read props$3.d)
368 - [7] Return freeze a$4_@0:TFunction
368 + [7] Return freeze a$4_@0
369 ```
370
371 ## Reactive Scopes
@@ -375,11 +375,11 @@ function Component(
375 props,
376 ) {
377 scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.d, read props$3.c] out=[] {
378 - [1] Const mutate a$4_@0:TFunction[1:7] = Array []
378 + [1] Const mutate a$4_@0[1:7] = Array []
379 [2] Call mutate a$4_@0.push(read props$3.a)
380 if (read props$3.b) {
381 [6] Call mutate a$4_@0.push(read props$3.d)
382 - return freeze a$4_@0:TFunction
382 + return freeze a$4_@0
383 }
384 [4] Call mutate a$4_@0.push(read props$3.c)
385 }
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+18 -18
@@ -35,9 +35,9 @@ function mayMutate() {}
35
36 ```
37 bb0:
38 - [1] Const mutate a$7_@0:TFunction[1:9] = Array []
39 - [2] Const mutate b$8_@0:TFunction[1:9] = Array []
40 - [3] If (read b$8_@0:TFunction) then:bb2 else:bb1 fallthrough=bb1
38 + [1] Const mutate a$7_@0[1:9] = Array []
39 + [2] Const mutate b$8_@0[1:9] = Array []
40 + [3] If (read b$8_@0) then:bb2 else:bb1 fallthrough=bb1
41 bb2:
42 predecessor blocks: bb0
43 [4] Call mutate a$7_@0.push(read props$6.p0)
@@ -51,7 +51,7 @@ bb4:
51 [8] Goto bb3
52 bb3:
53 predecessor blocks: bb4 bb1
54 - [9] Const mutate t6$16_@2 = JSX <read Foo$4 a={freeze a$7_@0:TFunction} b={freeze b$8_@0:TFunction} ></read Foo$4>
54 + [9] Const mutate t6$16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@0} ></read Foo$4>
55 [10] Return read t6$16_@2
56 ```
57
@@ -62,17 +62,17 @@ function Component(
62 props,
63 ) {
64 scope @0 [1:9] deps=[read props$6.p0, read props$6.p1, read props$6.p2] out=[a$7_@0] {
65 - [1] Const mutate a$7_@0:TFunction[1:9] = Array []
66 - [2] Const mutate b$8_@0:TFunction[1:9] = Array []
67 - if (read b$8_@0:TFunction) {
65 + [1] Const mutate a$7_@0[1:9] = Array []
66 + [2] Const mutate b$8_@0[1:9] = Array []
67 + if (read b$8_@0) {
68 [4] Call mutate a$7_@0.push(read props$6.p0)
69 }
70 if (read props$6.p1) {
71 [7] Call mutate b$8_@0.push(read props$6.p2)
72 }
73 }
74 - scope @2 [9:10] deps=[freeze a$7_@0:TFunction, freeze b$8_@0:TFunction] out=[$16_@2] {
75 - [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0:TFunction} b={freeze b$8_@0:TFunction} ></read Foo$4>
74 + scope @2 [9:10] deps=[freeze a$7_@0, freeze b$8_@0] out=[$16_@2] {
75 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@0} ></read Foo$4>
76 }
77 return read $16_@2
78 }
@@ -129,9 +129,9 @@ function Component$0(props$6) {
129
130 ```
131 bb0:
132 - [1] Const mutate a$9_@0:TFunction[1:10] = Array []
133 - [2] Const mutate b$10_@0:TFunction[1:10] = Array []
134 - [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction)
132 + [1] Const mutate a$9_@0[1:10] = Array []
133 + [2] Const mutate b$10_@0[1:10] = Array []
134 + [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0)
135 [4] If (read $11_@0) then:bb2 else:bb1 fallthrough=bb1
136 bb2:
137 predecessor blocks: bb0
@@ -146,7 +146,7 @@ bb4:
146 [9] Goto bb3
147 bb3:
148 predecessor blocks: bb4 bb1
149 - [10] Const mutate t6$19_@2 = JSX <read Foo$6 a={freeze a$9_@0:TFunction} b={freeze b$10_@0:TFunction} ></read Foo$6>
149 + [10] Const mutate t6$19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
150 [11] Return read t6$19_@2
151 ```
152
@@ -157,9 +157,9 @@ function Component(
157 props,
158 ) {
159 scope @0 [1:10] deps=[read props$8.p0, read props$8.p1, read props$8.p2] out=[a$9_@0] {
160 - [1] Const mutate a$9_@0:TFunction[1:10] = Array []
161 - [2] Const mutate b$10_@0:TFunction[1:10] = Array []
162 - [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction)
160 + [1] Const mutate a$9_@0[1:10] = Array []
161 + [2] Const mutate b$10_@0[1:10] = Array []
162 + [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0)
163 if (read $11_@0) {
164 [5] Call mutate a$9_@0.push(read props$8.p0)
165 }
@@ -167,8 +167,8 @@ function Component(
167 [8] Call mutate b$10_@0.push(read props$8.p2)
168 }
169 }
170 - scope @2 [10:11] deps=[freeze a$9_@0:TFunction, freeze b$10_@0:TFunction] out=[$19_@2] {
171 - [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0:TFunction} b={freeze b$10_@0:TFunction} ></read Foo$6>
170 + scope @2 [10:11] deps=[freeze a$9_@0, freeze b$10_@0] out=[$19_@2] {
171 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
172 }
173 return read $19_@2
174 }
compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md
+13 -13
@@ -22,22 +22,22 @@ function foo(a, b) {
22
23 ```
24 bb0:
25 - [1] Const mutate x$8_@0:TFunction[1:3] = Array []
25 + [1] Const mutate x$8_@0[1:3] = Array []
26 [2] Call mutate x$8_@0.push(read a$6)
27 [3] Const mutate $9:TPrimitive = "div"
28 - [4] JSX <read $9:TPrimitive>{freeze x$8_@0:TFunction}</read $9:TPrimitive>
29 - [5] Const mutate y$10_@1:TFunction[5:12] = Array []
28 + [4] JSX <read $9:TPrimitive>{freeze x$8_@0}</read $9:TPrimitive>
29 + [5] Const mutate y$10_@1[5:12] = Array []
30 [6] If (read x$8_@0.length) then:bb2 else:bb1 fallthrough=bb1
31 bb2:
32 predecessor blocks: bb0
33 - [7] Call mutate y$10_@1.push(read x$8_@0:TFunction)
33 + [7] Call mutate y$10_@1.push(read x$8_@0)
34 [8] Goto bb1
35 bb1:
36 predecessor blocks: bb2 bb0
37 - [9] If (read b$7:TFunction) then:bb4 else:bb3 fallthrough=bb3
37 + [9] If (read b$7) then:bb4 else:bb3 fallthrough=bb3
38 bb4:
39 predecessor blocks: bb1
40 - [10] Call mutate y$10_@1.push(read b$7:TFunction)
40 + [10] Call mutate y$10_@1.push(read b$7)
41 [11] Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
@@ -52,18 +52,18 @@ function foo(
52 b,
53 ) {
54 scope @0 [1:3] deps=[read a$6] out=[x$8_@0] {
55 - [1] Const mutate x$8_@0:TFunction[1:3] = Array []
55 + [1] Const mutate x$8_@0[1:3] = Array []
56 [2] Call mutate x$8_@0.push(read a$6)
57 }
58 [3] Const mutate $9:TPrimitive = "div"
59 - [4] JSX <read $9:TPrimitive>{freeze x$8_@0:TFunction}</read $9:TPrimitive>
60 - scope @1 [5:12] deps=[read x$8_@0:TFunction, read b$7:TFunction] out=[] {
61 - [5] Const mutate y$10_@1:TFunction[5:12] = Array []
59 + [4] JSX <read $9:TPrimitive>{freeze x$8_@0}</read $9:TPrimitive>
60 + scope @1 [5:12] deps=[read x$8_@0, read b$7] out=[] {
61 + [5] Const mutate y$10_@1[5:12] = Array []
62 if (read x$8_@0.length) {
63 - [7] Call mutate y$10_@1.push(read x$8_@0:TFunction)
63 + [7] Call mutate y$10_@1.push(read x$8_@0)
64 }
65 - if (read b$7:TFunction) {
66 - [10] Call mutate y$10_@1.push(read b$7:TFunction)
65 + if (read b$7) {
66 + [10] Call mutate y$10_@1.push(read b$7)
67 }
68 }
69 return
compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md
+6 -6
@@ -24,9 +24,9 @@ function foo(x, y, z) {
24
25 ```
26 bb0:
27 - [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8]
27 + [1] Const mutate items$9_@0[1:10] = Array [read z$8]
28 [2] Call mutate items$9_@0.push(read x$6)
29 - [3] Const mutate items2$10_@1:TFunction[3:7] = Array []
29 + [3] Const mutate items2$10_@1[3:7] = Array []
30 [4] If (read x$6) then:bb2 else:bb1 fallthrough=bb1
31 bb2:
32 predecessor blocks: bb0
@@ -41,7 +41,7 @@ bb4:
41 [9] Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
44 - [10] Return freeze items2$10_@1:TFunction
44 + [10] Return freeze items2$10_@1
45 ```
46
47 ## Reactive Scopes
@@ -53,10 +53,10 @@ function foo(
53 z,
54 ) {
55 scope @0 [1:10] deps=[read z$8, read x$6, read y$7] out=[] {
56 - [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8]
56 + [1] Const mutate items$9_@0[1:10] = Array [read z$8]
57 [2] Call mutate items$9_@0.push(read x$6)
58 scope @1 [3:7] deps=[read x$6, read y$7] out=[items2$10_@1] {
59 - [3] Const mutate items2$10_@1:TFunction[3:7] = Array []
59 + [3] Const mutate items2$10_@1[3:7] = Array []
60 if (read x$6) {
61 [5] Call mutate items2$10_@1.push(read y$7)
62 }
@@ -65,7 +65,7 @@ function foo(
65 [8] Call mutate items$9_@0.push(read x$6)
66 }
67 }
68 - return freeze items2$10_@1:TFunction
68 + return freeze items2$10_@1
69 }
70
71 ```
compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md
+2 -2
@@ -23,7 +23,7 @@ function foo(a, b, c) {
23
24 ```
25 bb0:
26 - [1] Const mutate x$10_@0:TFunction[1:8] = Array []
26 + [1] Const mutate x$10_@0[1:8] = Array []
27 [2] If (read a$7) then:bb2 else:bb1 fallthrough=bb1
28 bb2:
29 predecessor blocks: bb0
@@ -57,7 +57,7 @@ function foo(
57 c,
58 ) {
59 scope @0 [1:8] deps=[read a$7, read b$8, read c$9] out=[] {
60 - [1] Const mutate x$10_@0:TFunction[1:8] = Array []
60 + [1] Const mutate x$10_@0[1:8] = Array []
61 if (read a$7) {
62 if (read b$8) {
63 if (read c$9) {
compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md
+2 -2
@@ -18,7 +18,7 @@ function foo(a, b, c) {
18
19 ```
20 bb0:
21 - [1] Const mutate y$8_@0:TFunction[1:6] = Array []
21 + [1] Const mutate y$8_@0[1:6] = Array []
22 [2] If (read a$5) then:bb3 else:bb1 fallthrough=bb1
23 bb3:
24 predecessor blocks: bb0
@@ -41,7 +41,7 @@ function foo(
41 c,
42 ) {
43 scope @0 [1:6] deps=[read a$5, read b$6, read c$7] out=[] {
44 - [1] Const mutate y$8_@0:TFunction[1:6] = Array []
44 + [1] Const mutate y$8_@0[1:6] = Array []
45 if (read a$5) {
46 if (read b$6) {
47 [4] Call mutate y$8_@0.push(read c$7)
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+8 -8
@@ -94,7 +94,7 @@ function cond$0(x$2) {}
94 bb0:
95 [1] Let mutate a$18_@0[1:23] = Object { }
96 [2] Let mutate b$20_@0[1:23] = Object { }
97 - [3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
97 + [3] Let mutate c$22_@0[1:23] = Object { }
98 [4] Let mutate d$24_@0[1:23] = Object { }
99 [5] While test=bb1 loop=bb3 fallthrough=bb2
100 bb1:
@@ -105,8 +105,8 @@ bb3:
105 predecessor blocks: bb1
106 [8] Const mutate z$19_@0[1:23] = read a$18_@0
107 [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
108 - [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
109 - [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
108 + [10] Reassign mutate b$20_@0[1:23] = read c$22_@0
109 + [11] Reassign mutate c$22_@0[1:23] = read d$24_@0
110 [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
111 [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
112 [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
@@ -122,7 +122,7 @@ bb7:
122 [18] If (read b$20_@0) then:bb9 else:bb9 fallthrough=bb9
123 bb9:
124 predecessor blocks: bb7
125 - [19] If (read c$22_@0:TPrimitive) then:bb11 else:bb11 fallthrough=bb11
125 + [19] If (read c$22_@0) then:bb11 else:bb11 fallthrough=bb11
126 bb11:
127 predecessor blocks: bb9
128 [20] If (read d$24_@0) then:bb13 else:bb13 fallthrough=bb13
@@ -142,7 +142,7 @@ function Component(
142 scope @0 [1:23] deps=[] out=[] {
143 [1] Let mutate a$18_@0[1:23] = Object { }
144 [2] Let mutate b$20_@0[1:23] = Object { }
145 - [3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
145 + [3] Let mutate c$22_@0[1:23] = Object { }
146 [4] Let mutate d$24_@0[1:23] = Object { }
147 while (
148 [6] Const mutate $17:TPrimitive = true
@@ -150,8 +150,8 @@ function Component(
150 ) {
151 [8] Const mutate z$19_@0[1:23] = read a$18_@0
152 [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
153 - [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
154 - [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
153 + [10] Reassign mutate b$20_@0[1:23] = read c$22_@0
154 + [11] Reassign mutate c$22_@0[1:23] = read d$24_@0
155 [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
156 [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
157 [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
@@ -163,7 +163,7 @@ function Component(
163 }
164 if (read b$20_@0) {
165 }
166 - if (read c$22_@0:TPrimitive) {
166 + if (read c$22_@0) {
167 }
168 if (read d$24_@0) {
169 }
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md
+6 -6
@@ -19,9 +19,9 @@ function foo(a, b, c) {
19
20 ```
21 bb0:
22 - [1] Const mutate x$9_@0:TFunction[1:6] = Array []
23 - [2] Const mutate y$10_@0:TFunction[1:6] = Array []
24 - [3] If (read x$9_@0:TFunction) then:bb1 else:bb1 fallthrough=bb1
22 + [1] Const mutate x$9_@0[1:6] = Array []
23 + [2] Const mutate y$10_@0[1:6] = Array []
24 + [3] If (read x$9_@0) then:bb1 else:bb1 fallthrough=bb1
25 bb1:
26 predecessor blocks: bb0
27 [4] Call mutate y$10_@0.push(read a$6)
@@ -38,9 +38,9 @@ function foo(
38 c,
39 ) {
40 scope @0 [1:6] deps=[read a$6, read b$7] out=[] {
41 - [1] Const mutate x$9_@0:TFunction[1:6] = Array []
42 - [2] Const mutate y$10_@0:TFunction[1:6] = Array []
43 - if (read x$9_@0:TFunction) {
41 + [1] Const mutate x$9_@0[1:6] = Array []
42 + [2] Const mutate y$10_@0[1:6] = Array []
43 + if (read x$9_@0) {
44 }
45 [4] Call mutate y$10_@0.push(read a$6)
46 [5] Call mutate x$9_@0.push(read b$7)
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md
+4 -4
@@ -15,8 +15,8 @@ function foo(a, b) {
15
16 ```
17 bb0:
18 - [1] Const mutate x$7_@0:TFunction[1:5] = Array []
19 - [2] Const mutate y$8_@0:TFunction[1:5] = Array []
18 + [1] Const mutate x$7_@0[1:5] = Array []
19 + [2] Const mutate y$8_@0[1:5] = Array []
20 [3] Call mutate x$7_@0.push(read a$5)
21 [4] Call mutate y$8_@0.push(read b$6)
22 [5] Return
@@ -30,8 +30,8 @@ function foo(
30 b,
31 ) {
32 scope @0 [1:5] deps=[read a$5, read b$6] out=[] {
33 - [1] Const mutate x$7_@0:TFunction[1:5] = Array []
34 - [2] Const mutate y$8_@0:TFunction[1:5] = Array []
33 + [1] Const mutate x$7_@0[1:5] = Array []
34 + [2] Const mutate y$8_@0[1:5] = Array []
35 [3] Call mutate x$7_@0.push(read a$5)
36 [4] Call mutate y$8_@0.push(read b$6)
37 }
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md
+4 -4
@@ -15,8 +15,8 @@ function foo(a, b) {
15
16 ```
17 bb0:
18 - [1] Const mutate x$7_@0:TFunction[1:5] = Array []
19 - [2] Const mutate y$8_@1:TFunction[2:4] = Array []
18 + [1] Const mutate x$7_@0[1:5] = Array []
19 + [2] Const mutate y$8_@1[2:4] = Array []
20 [3] Call mutate y$8_@1.push(read b$6)
21 [4] Call mutate x$7_@0.push(read a$5)
22 [5] Return
@@ -30,9 +30,9 @@ function foo(
30 b,
31 ) {
32 scope @0 [1:5] deps=[read b$6, read a$5] out=[] {
33 - [1] Const mutate x$7_@0:TFunction[1:5] = Array []
33 + [1] Const mutate x$7_@0[1:5] = Array []
34 scope @1 [2:4] deps=[read b$6] out=[] {
35 - [2] Const mutate y$8_@1:TFunction[2:4] = Array []
35 + [2] Const mutate y$8_@1[2:4] = Array []
36 [3] Call mutate y$8_@1.push(read b$6)
37 }
38 [4] Call mutate x$7_@0.push(read a$5)
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md
+9 -9
@@ -21,11 +21,11 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$11_@0:TFunction[1:11] = Array []
24 + [1] Const mutate x$11_@0[1:11] = Array []
25 [2] If (read a$8) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$12_@1:TFunction[3:7] = Array []
28 + [3] Const mutate y$12_@1[3:7] = Array []
29 [4] If (read b$9) then:bb4 else:bb3 fallthrough=bb3
30 bb4:
31 predecessor blocks: bb2
@@ -34,12 +34,12 @@ bb4:
34 bb3:
35 predecessor blocks: bb4 bb2
36 [7] Const mutate $13:TPrimitive = "div"
37 - [8] Const mutate t8$15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
37 + [8] Const mutate t8$15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1}</read $13:TPrimitive>
38 [9] Call mutate x$11_@0.push(read t8$15_@2)
39 [10] Goto bb1
40 bb1:
41 predecessor blocks: bb3 bb0
42 - [11] Return freeze x$11_@0:TFunction
42 + [11] Return freeze x$11_@0
43 ```
44
45 ## Reactive Scopes
@@ -51,22 +51,22 @@ function foo(
51 c,
52 ) {
53 scope @0 [1:11] deps=[read a$8, read b$9, read c$10] out=[x$11_@0] {
54 - [1] Const mutate x$11_@0:TFunction[1:11] = Array []
54 + [1] Const mutate x$11_@0[1:11] = Array []
55 if (read a$8) {
56 scope @1 [3:7] deps=[read b$9, read c$10] out=[y$12_@1] {
57 - [3] Const mutate y$12_@1:TFunction[3:7] = Array []
57 + [3] Const mutate y$12_@1[3:7] = Array []
58 if (read b$9) {
59 [5] Call mutate y$12_@1.push(read c$10)
60 }
61 }
62 [7] Const mutate $13:TPrimitive = "div"
63 - scope @2 [8:9] deps=[freeze y$12_@1:TFunction] out=[$15_@2] {
64 - [8] Const mutate $15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
63 + scope @2 [8:9] deps=[freeze y$12_@1] out=[$15_@2] {
64 + [8] Const mutate $15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1}</read $13:TPrimitive>
65 }
66 [9] Call mutate x$11_@0.push(read $15_@2)
67 }
68 }
69 - return freeze x$11_@0:TFunction
69 + return freeze x$11_@0
70 }
71
72 ```
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md
+4 -4
@@ -17,8 +17,8 @@ function foo(a, b, c) {
17
18 ```
19 bb0:
20 - [1] Const mutate x$9_@0:TFunction[1:8] = Array []
21 - [2] Const mutate y$10_@0:TFunction[1:8] = Array []
20 + [1] Const mutate x$9_@0[1:8] = Array []
21 + [2] Const mutate y$10_@0[1:8] = Array []
22 [3] While test=bb1 loop=bb3 fallthrough=bb2
23 bb1:
24 predecessor blocks: bb0 bb3
@@ -42,8 +42,8 @@ function foo(
42 c,
43 ) {
44 scope @0 [1:8] deps=[read c$8, read b$7, read a$6] out=[] {
45 - [1] Const mutate x$9_@0:TFunction[1:8] = Array []
46 - [2] Const mutate y$10_@0:TFunction[1:8] = Array []
45 + [1] Const mutate x$9_@0[1:8] = Array []
46 + [2] Const mutate y$10_@0[1:8] = Array []
47 while (
48 read c$8
49 ) {
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md
+8 -8
@@ -21,11 +21,11 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$9_@0:TFunction[1:9] = Array []
24 + [1] Const mutate x$9_@0[1:9] = Array []
25 [2] If (read a$6) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$10_@0:TFunction[1:9] = Array []
28 + [3] Const mutate y$10_@0[1:9] = Array []
29 [4] If (read b$7) then:bb4 else:bb3 fallthrough=bb3
30 bb4:
31 predecessor blocks: bb2
@@ -33,11 +33,11 @@ bb4:
33 [6] Goto bb3
34 bb3:
35 predecessor blocks: bb4 bb2
36 - [7] Call mutate x$9_@0.push(mutate y$10_@0:TFunction)
36 + [7] Call mutate x$9_@0.push(mutate y$10_@0)
37 [8] Goto bb1
38 bb1:
39 predecessor blocks: bb3 bb0
40 - [9] Return freeze x$9_@0:TFunction
40 + [9] Return freeze x$9_@0
41 ```
42
43 ## Reactive Scopes
@@ -49,16 +49,16 @@ function foo(
49 c,
50 ) {
51 scope @0 [1:9] deps=[read a$6, read b$7, read c$8] out=[x$9_@0] {
52 - [1] Const mutate x$9_@0:TFunction[1:9] = Array []
52 + [1] Const mutate x$9_@0[1:9] = Array []
53 if (read a$6) {
54 - [3] Const mutate y$10_@0:TFunction[1:9] = Array []
54 + [3] Const mutate y$10_@0[1:9] = Array []
55 if (read b$7) {
56 [5] Call mutate y$10_@0.push(read c$8)
57 }
58 - [7] Call mutate x$9_@0.push(mutate y$10_@0:TFunction)
58 + [7] Call mutate x$9_@0.push(mutate y$10_@0)
59 }
60 }
61 - return freeze x$9_@0:TFunction
61 + return freeze x$9_@0
62 }
63
64 ```
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md
+4 -4
@@ -19,10 +19,10 @@ function foo() {
19 ```
20 bb0:
21 [1] Const mutate x$4_@0:TObject[1:6] = Object { }
22 - [2] Const mutate y$5_@1:TFunction[2:5] = Array []
22 + [2] Const mutate y$5_@1[2:5] = Array []
23 [3] Const mutate z$6_@1:TObject[2:5] = Object { }
24 [4] Call mutate y$5_@1.push(mutate z$6_@1:TObject)
25 - [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1:TFunction
25 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
26 [6] Return freeze x$4_@0:TObject
27 ```
28
@@ -34,11 +34,11 @@ function foo(
34 scope @0 [1:6] deps=[] out=[x$4_@0] {
35 [1] Const mutate x$4_@0:TObject[1:6] = Object { }
36 scope @1 [2:5] deps=[] out=[y$5_@1] {
37 - [2] Const mutate y$5_@1:TFunction[2:5] = Array []
37 + [2] Const mutate y$5_@1[2:5] = Array []
38 [3] Const mutate z$6_@1:TObject[2:5] = Object { }
39 [4] Call mutate y$5_@1.push(mutate z$6_@1:TObject)
40 }
41 - [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1:TFunction
41 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
42 }
43 return freeze x$4_@0:TObject
44 }
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md
+9 -9
@@ -20,14 +20,14 @@ function foo(a, b, c) {
20
21 ```
22 bb0:
23 - [1] Const mutate x$11_@0:TFunction[1:11] = Array []
23 + [1] Const mutate x$11_@0[1:11] = Array []
24 [2] If (read a$8) then:bb2 else:bb3 fallthrough=bb1
25 bb2:
26 predecessor blocks: bb0
27 - [3] Const mutate y$12_@1:TFunction[3:5] = Array []
27 + [3] Const mutate y$12_@1[3:5] = Array []
28 [4] Call mutate y$12_@1.push(read b$9)
29 [5] Const mutate $13:TPrimitive = "div"
30 - [6] Const mutate t7$14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
30 + [6] Const mutate t7$14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1}</read $13:TPrimitive>
31 [7] Call mutate x$11_@0.push(read t7$14_@2)
32 [8] Goto bb1
33 bb3:
@@ -36,7 +36,7 @@ bb3:
36 [10] Goto bb1
37 bb1:
38 predecessor blocks: bb2 bb3
39 - [11] Return freeze x$11_@0:TFunction
39 + [11] Return freeze x$11_@0
40 ```
41
42 ## Reactive Scopes
@@ -48,22 +48,22 @@ function foo(
48 c,
49 ) {
50 scope @0 [1:11] deps=[read a$8, read b$9, read c$10] out=[x$11_@0] {
51 - [1] Const mutate x$11_@0:TFunction[1:11] = Array []
51 + [1] Const mutate x$11_@0[1:11] = Array []
52 if (read a$8) {
53 scope @1 [3:5] deps=[read b$9] out=[y$12_@1] {
54 - [3] Const mutate y$12_@1:TFunction[3:5] = Array []
54 + [3] Const mutate y$12_@1[3:5] = Array []
55 [4] Call mutate y$12_@1.push(read b$9)
56 }
57 [5] Const mutate $13:TPrimitive = "div"
58 - scope @2 [6:7] deps=[freeze y$12_@1:TFunction] out=[$14_@2] {
59 - [6] Const mutate $14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
58 + scope @2 [6:7] deps=[freeze y$12_@1] out=[$14_@2] {
59 + [6] Const mutate $14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1}</read $13:TPrimitive>
60 }
61 [7] Call mutate x$11_@0.push(read $14_@2)
62 } else {
63 [9] Call mutate x$11_@0.push(read c$10)
64 }
65 }
66 - return freeze x$11_@0:TFunction
66 + return freeze x$11_@0
67 }
68
69 ```
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md
+5 -5
@@ -19,7 +19,7 @@ function f(a, b) {
19
20 ```
21 bb0:
22 - [1] Const mutate x$10_@0:TFunction[1:8] = Array []
22 + [1] Const mutate x$10_@0[1:8] = Array []
23 [2] Const mutate $11:TPrimitive = 1
24 [3] Const mutate $12:TPrimitive = Binary read a$8.length === read $11:TPrimitive
25 [4] If (read $12:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
@@ -33,7 +33,7 @@ bb4:
33 bb1:
34 predecessor blocks: bb4 bb2 bb0
35 [8] Const mutate $13:TPrimitive = "div"
36 - [9] Const mutate t4$15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0:TFunction}</read $13:TPrimitive>
36 + [9] Const mutate t4$15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0}</read $13:TPrimitive>
37 [10] Return read t4$15_@1
38 ```
39
@@ -45,7 +45,7 @@ function f(
45 b,
46 ) {
47 scope @0 [1:8] deps=[read a$8.length, read b$9] out=[x$10_@0] {
48 - [1] Const mutate x$10_@0:TFunction[1:8] = Array []
48 + [1] Const mutate x$10_@0[1:8] = Array []
49 [2] Const mutate $11:TPrimitive = 1
50 [3] Const mutate $12:TPrimitive = Binary read a$8.length === read $11:TPrimitive
51 if (read $12:TPrimitive) {
@@ -55,8 +55,8 @@ function f(
55 }
56 }
57 [8] Const mutate $13:TPrimitive = "div"
58 - scope @1 [9:10] deps=[freeze x$10_@0:TFunction] out=[$15_@1] {
59 - [9] Const mutate $15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0:TFunction}</read $13:TPrimitive>
58 + scope @1 [9:10] deps=[freeze x$10_@0] out=[$15_@1] {
59 + [9] Const mutate $15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0}</read $13:TPrimitive>
60 }
61 return read $15_@1
62 }
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+12 -12
@@ -23,19 +23,19 @@ function Component(props) {
23
24 ```
25 bb0:
26 - [1] Let mutate x$7_@0:TFunction[1:7] = Array []
26 + [1] Let mutate x$7_@0[1:7] = Array []
27 [2] Call mutate x$7_@0.push(read props$6.p0)
28 - [3] Const mutate y$8:TFunction = read x$7_@0:TFunction
28 + [3] Const mutate y$8 = read x$7_@0
29 [4] If (read props$6.p1) then:bb2 else:bb1 fallthrough=bb1
30 bb2:
31 predecessor blocks: bb0
32 - [5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
32 + [5] Reassign mutate x$7_@0[1:7] = Array []
33 [6] Goto bb1
34 bb1:
35 predecessor blocks: bb2 bb0
36 - [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
36 + [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0} ></read Component$0>
37 [8] Call read y$8.push(read props$6.p2)
38 - [9] Const mutate t6$15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8:TFunction} ></read Component$0>
38 + [9] Const mutate t6$15_@2 = JSX <read Component$0 x={read x$7_@0} y={read y$8} ></read Component$0>
39 [10] Return read t6$15_@2
40 ```
41
@@ -46,19 +46,19 @@ function Component(
46 props,
47 ) {
48 scope @0 [1:7] deps=[read props$6.p0, read props$6.p1] out=[x$7_@0] {
49 - [1] Let mutate x$7_@0:TFunction[1:7] = Array []
49 + [1] Let mutate x$7_@0[1:7] = Array []
50 [2] Call mutate x$7_@0.push(read props$6.p0)
51 - [3] Const mutate y$8:TFunction = read x$7_@0:TFunction
51 + [3] Const mutate y$8 = read x$7_@0
52 if (read props$6.p1) {
53 - [5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
53 + [5] Reassign mutate x$7_@0[1:7] = Array []
54 }
55 }
56 - scope @1 [7:8] deps=[freeze x$7_@0:TFunction] out=[] {
57 - [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
56 + scope @1 [7:8] deps=[freeze x$7_@0] out=[] {
57 + [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0} ></read Component$0>
58 }
59 [8] Call read y$8.push(read props$6.p2)
60 - scope @2 [9:10] deps=[read x$7_@0:TFunction, read y$8:TFunction] out=[$15_@2] {
61 - [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8:TFunction} ></read Component$0>
60 + scope @2 [9:10] deps=[read x$7_@0, read y$8] out=[$15_@2] {
61 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0} y={read y$8} ></read Component$0>
62 }
63 return read $15_@2
64 }
compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md
+14 -14
@@ -34,7 +34,7 @@ function foo(a, b, c) {
34
35 ```
36 bb0:
37 - [1] Const mutate x$16_@0:TFunction[1:5] = Array []
37 + [1] Const mutate x$16_@0[1:5] = Array []
38 [2] If (read a$13) then:bb2 else:bb1 fallthrough=bb1
39 bb2:
40 predecessor blocks: bb0
@@ -43,21 +43,21 @@ bb2:
43 bb1:
44 predecessor blocks: bb2 bb0
45 [5] Const mutate $17:TPrimitive = "div"
46 - [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0:TFunction}</read $17:TPrimitive>
46 + [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0}</read $17:TPrimitive>
47 [7] Const mutate $20:TPrimitive = 0
48 - [8] Let mutate x$22_@2:TFunction[8:15] = undefined
48 + [8] Let mutate x$22_@2[8:15] = undefined
49 [8] Switch (read b$14)
50 Case read $20:TPrimitive: bb5
51 Default: bb4
52 Fallthrough: bb3
53 bb5:
54 predecessor blocks: bb1
55 - [9] Reassign mutate x$22_@2:TFunction[8:15] = Array []
55 + [9] Reassign mutate x$22_@2[8:15] = Array []
56 [10] Call mutate x$22_@2.push(read b$14)
57 [11] Goto bb3
58 bb4:
59 predecessor blocks: bb1
60 - [12] Reassign mutate x$22_@2:TFunction[8:15] = Array []
60 + [12] Reassign mutate x$22_@2[8:15] = Array []
61 [13] Call mutate x$22_@2.push(read c$15)
62 [14] Goto bb3
63 bb3:
@@ -66,7 +66,7 @@ bb3:
66 [16] Const mutate $26 = "\n "
67 [17] Const mutate $27 = "\n "
68 [18] Const mutate $28 = "\n "
69 - [19] Const mutate t9$31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2:TFunction}{read $28}</read $25:TPrimitive>
69 + [19] Const mutate t9$31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2}{read $28}</read $25:TPrimitive>
70 [20] Return read t9$31_@3
71 ```
72
@@ -79,26 +79,26 @@ function foo(
79 c,
80 ) {
81 scope @0 [1:5] deps=[read a$13] out=[x$16_@0] {
82 - [1] Const mutate x$16_@0:TFunction[1:5] = Array []
82 + [1] Const mutate x$16_@0[1:5] = Array []
83 if (read a$13) {
84 [3] Call mutate x$16_@0.push(read a$13)
85 }
86 }
87 [5] Const mutate $17:TPrimitive = "div"
88 - scope @1 [6:7] deps=[freeze x$16_@0:TFunction] out=[y$19_@1] {
89 - [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0:TFunction}</read $17:TPrimitive>
88 + scope @1 [6:7] deps=[freeze x$16_@0] out=[y$19_@1] {
89 + [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0}</read $17:TPrimitive>
90 }
91 [7] Const mutate $20:TPrimitive = 0
92 scope @2 [8:15] deps=[read b$14, read c$15] out=[x$22_@2] {
93 - [8] Let mutate x$22_@2:TFunction[8:15] = undefined
93 + [8] Let mutate x$22_@2[8:15] = undefined
94 switch (read b$14) {
95 case read $20:TPrimitive: {
96 - [9] Reassign mutate x$22_@2:TFunction[8:15] = Array []
96 + [9] Reassign mutate x$22_@2[8:15] = Array []
97 [10] Call mutate x$22_@2.push(read b$14)
98 break bb3
99 }
100 default: {
101 - [12] Reassign mutate x$22_@2:TFunction[8:15] = Array []
101 + [12] Reassign mutate x$22_@2[8:15] = Array []
102 [13] Call mutate x$22_@2.push(read c$15)
103 }
104 }
@@ -107,8 +107,8 @@ function foo(
107 [16] Const mutate $26 = "\n "
108 [17] Const mutate $27 = "\n "
109 [18] Const mutate $28 = "\n "
110 - scope @3 [19:20] deps=[read y$19_@1, freeze x$22_@2:TFunction] out=[$31_@3] {
111 - [19] Const mutate $31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2:TFunction}{read $28}</read $25:TPrimitive>
110 + scope @3 [19:20] deps=[read y$19_@1, freeze x$22_@2] out=[$31_@3] {
111 + [19] Const mutate $31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2}{read $28}</read $25:TPrimitive>
112 }
113 return read $31_@3
114 }
compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md
+7 -7
@@ -21,13 +21,13 @@ function Component(props) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$7_@0:TFunction[1:7] = Array []
24 + [1] Const mutate x$7_@0[1:7] = Array []
25 [2] Call mutate x$7_@0.push(read props$6.p0)
26 - [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
26 + [3] Const mutate y$8_@0[1:7] = read x$7_@0
27 [4] Const mutate x$9_@1 = Array []
28 [5] Const mutate _$10_@2 = JSX <read Component$0 x={freeze x$9_@1} ></read Component$0>
29 [6] Call mutate y$8_@0.push(read props$6.p1)
30 - [7] Const mutate t7$11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0:TFunction} ></read Component$0>
30 + [7] Const mutate t7$11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
31 [8] Return read t7$11_@3
32 ```
33
@@ -38,9 +38,9 @@ function Component(
38 props,
39 ) {
40 scope @0 [1:7] deps=[read props$6.p0, read props$6.p1] out=[y$8_@0] {
41 - [1] Const mutate x$7_@0:TFunction[1:7] = Array []
41 + [1] Const mutate x$7_@0[1:7] = Array []
42 [2] Call mutate x$7_@0.push(read props$6.p0)
43 - [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
43 + [3] Const mutate y$8_@0[1:7] = read x$7_@0
44 scope @1 [4:5] deps=[] out=[x$9_@1] {
45 [4] Const mutate x$9_@1 = Array []
46 }
@@ -49,8 +49,8 @@ function Component(
49 }
50 [6] Call mutate y$8_@0.push(read props$6.p1)
51 }
52 - scope @3 [7:8] deps=[read x$9_@1, freeze y$8_@0:TFunction] out=[$11_@3] {
53 - [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0:TFunction} ></read Component$0>
52 + scope @3 [7:8] deps=[read x$9_@1, freeze y$8_@0] out=[$11_@3] {
53 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
54 }
55 return read $11_@3
56 }
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+7 -7
@@ -32,7 +32,7 @@ function Component(props) {
32
33 ```
34 bb0:
35 - [1] Const mutate x$10_@1:TFunction[1:12] = Array []
35 + [1] Const mutate x$10_@1[1:12] = Array []
36 [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
37 [3] Const mutate $12:TPrimitive = false
38 [4] Const mutate $13:TPrimitive = true
@@ -50,11 +50,11 @@ bb6:
50 [9] Goto bb1
51 bb2:
52 predecessor blocks: bb0
53 - [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
53 + [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1
54 [11] Goto bb1
55 bb1:
56 predecessor blocks: bb0 bb6 bb2
57 - [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
57 + [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1} ></read Component$0>
58 [13] Call read y$11_@1.push(read props$9.p4)
59 [14] Const mutate t7$22_@3 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@2}</read Component$0>
60 [15] Return read t7$22_@3
@@ -67,7 +67,7 @@ function Component(
67 props,
68 ) {
69 scope @1 [1:12] deps=[read props$9.p0, read props$9.p2] out=[x$10_@1] {
70 - [1] Const mutate x$10_@1:TFunction[1:12] = Array []
70 + [1] Const mutate x$10_@1[1:12] = Array []
71 [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
72 [3] Const mutate $12:TPrimitive = false
73 [4] Const mutate $13:TPrimitive = true
@@ -85,12 +85,12 @@ function Component(
85 break bb1
86 }
87 case read $12:TPrimitive: {
88 - [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
88 + [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1
89 }
90 }
91 }
92 - scope @2 [12:13] deps=[freeze x$10_@1:TFunction] out=[child$19_@2] {
93 - [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
92 + scope @2 [12:13] deps=[freeze x$10_@1] out=[child$19_@2] {
93 + [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1} ></read Component$0>
94 }
95 [13] Call read y$11_@1.push(read props$9.p4)
96 scope @3 [14:15] deps=[freeze y$11_@1:TPrimitive, read child$19_@2] out=[$22_@3] {
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+7 -7
@@ -27,7 +27,7 @@ function Component(props) {
27
28 ```
29 bb0:
30 - [1] Const mutate x$9_@1:TFunction[1:12] = Array []
30 + [1] Const mutate x$9_@1[1:12] = Array []
31 [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
32 [3] Const mutate $11:TPrimitive = false
33 [4] Const mutate $12:TPrimitive = true
@@ -44,11 +44,11 @@ bb4:
44 [9] Goto bb2
45 bb2:
46 predecessor blocks: bb4 bb0
47 - [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
47 + [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1
48 [11] Goto bb1
49 bb1:
50 predecessor blocks: bb2 bb0
51 - [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
51 + [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1} ></read Component$0>
52 [13] Call read y$10_@1.push(read props$8.p4)
53 [14] Const mutate t8$23_@4 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@3}</read Component$0>
54 [15] Return read t8$23_@4
@@ -61,7 +61,7 @@ function Component(
61 props,
62 ) {
63 scope @1 [1:12] deps=[read props$8.p0, read props$8.p2, read props$8.p3] out=[x$9_@1] {
64 - [1] Const mutate x$9_@1:TFunction[1:12] = Array []
64 + [1] Const mutate x$9_@1[1:12] = Array []
65 [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
66 [3] Const mutate $11:TPrimitive = false
67 [4] Const mutate $12:TPrimitive = true
@@ -74,12 +74,12 @@ function Component(
74 }
75 }
76 case read $11:TPrimitive: {
77 - [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
77 + [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1
78 }
79 }
80 }
81 - scope @3 [12:13] deps=[freeze x$9_@1:TFunction] out=[child$19_@3] {
82 - [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
81 + scope @3 [12:13] deps=[freeze x$9_@1] out=[child$19_@3] {
82 + [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1} ></read Component$0>
83 }
84 [13] Call read y$10_@1.push(read props$8.p4)
85 scope @4 [14:15] deps=[read y$10_@1:TPrimitive, read child$19_@3] out=[$23_@4] {
compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.expect.md
+2 -2
@@ -28,7 +28,7 @@ bb2:
28 [6] Goto bb1
29 bb1:
30 predecessor blocks: bb2 bb0
31 - [7] Const mutate z$12_@3:TPrimitive = Call mutate foo$2:TFunction()
31 + [7] Const mutate z$12_@3 = Call mutate foo$2:TFunction()
32 [8] Return
33 ```
34
@@ -50,7 +50,7 @@ function component(
50 }
51 }
52 scope @3 [7:8] deps=[] out=[] {
53 - [7] Const mutate z$12_@3:TPrimitive = Call mutate foo$2:TFunction()
53 + [7] Const mutate z$12_@3 = Call mutate foo$2:TFunction()
54 }
55 return
56 }