@samitouri / QOS-React-2 / commits / 241101c08a

[builtins] Fix effects: capture -> read, store -> mutate

--- I didn't properly understand Capture and Store effects previously, just correcting those mistakes! These functions are all synchronously mutative, so they should use Read / Mutate, not Capture + Store

Mofei Zhang committed Mar 22, 2023 at 15:50 UTC 241101c08a0821ec700ac9470854bfa9a193cda4
1 file changed +5 -9
compiler/forget/src/HIR/ObjectShape.ts
+5 -9
@@ -86,7 +86,7 @@ addShape(BUILTIN_SHAPES, ArrayShapeId, [
86 positionalParams: [Effect.Read],
87 restParam: null,
88 returnType: null,
89 - calleeEffect: Effect.Capture,
89 + calleeEffect: Effect.Read,
90 }),
91 ],
92 [
@@ -98,7 +98,7 @@ addShape(BUILTIN_SHAPES, ArrayShapeId, [
98 kind: "Object",
99 shapeId: ArrayShapeId,
100 },
101 - calleeEffect: Effect.Capture,
101 + calleeEffect: Effect.Read,
102 }),
103 ],
104 ["length", PRIMITIVE_TYPE],
@@ -107,10 +107,8 @@ addShape(BUILTIN_SHAPES, ArrayShapeId, [
107 addFunction(BUILTIN_SHAPES, [], {
108 positionalParams: [],
109 restParam: Effect.Capture,
110 - returnType: {
111 - kind: "Primitive",
112 - },
113 - calleeEffect: Effect.Store,
110 + returnType: PRIMITIVE_TYPE,
111 + calleeEffect: Effect.Mutate,
112 }),
113 ],
114 // TODO: rest of Array properties
@@ -123,9 +121,7 @@ addShape(BUILTIN_SHAPES, ObjectShapeId, [
121 addFunction(BUILTIN_SHAPES, [], {
122 positionalParams: [],
123 restParam: null,
126 - returnType: {
127 - kind: "Primitive",
128 - },
124 + returnType: PRIMITIVE_TYPE,
125 calleeEffect: Effect.Read,
126 }),
127 ],