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

[hir] remove constant propagation for ComputedCall

Mofei Zhang committed Mar 21, 2023 at 14:57 UTC ab1d11a446e184ffdcae4b762c51a477511955e0
3 files changed +2 -28
compiler/forget/src/Optimization/ConstantPropagation.ts
-26
@@ -192,32 +192,6 @@ function evaluateInstruction(
192 }
193 return null;
194 }
195 - case "ComputedCall": {
196 - const property = read(constants, value.property);
197 - if (
198 - property !== null &&
199 - typeof property.value === "string" &&
200 - isValidIdentifier(property.value)
201 - ) {
202 - const nextValue: InstructionValue = {
203 - kind: "PropertyCall",
204 - args: value.args,
205 - loc: value.loc,
206 - property: property.value,
207 - receiver: value.receiver,
208 - };
209 - // Future-proofing: when we add support for optional computed calls,
210 - // we'll need to copy the value here
211 - if ((value as any).optional) {
212 - invariant(
213 - false,
214 - "TODO: translate optional computed load to optional property load"
215 - );
216 - }
217 - instr.value = nextValue;
218 - }
219 - return null;
220 - }
195 case "BinaryExpression": {
196 const lhsValue = read(constants, value.left);
197 const rhsValue = read(constants, value.right);
compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md
+1 -1
@@ -38,7 +38,7 @@ function Component() {
38 console.log("B");
39 changeF(x);
40 console.log("arg");
41 - x.f(1);
41 + x["f"](1);
42 $[0] = x;
43 } else {
44 x = $[0];
compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component(props) {
22 if (c_0) {
23 x = {};
24 x.foo = x.foo + x.bar;
25 - x.foo(props.foo);
25 + x["foo"](props.foo);
26 $[0] = props.foo;
27 $[1] = x;
28 } else {