[bugfix] Fix constant propagation to ObjectMethods
Mofei Zhang committed
Dec 6, 2023 at 13:20 UTC
995f4b0528430c6d37e03e0726fbd22ea8273cf7
4 files changed
+5
-3
compiler/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts
+1
@@ -434,6 +434,7 @@ function evaluateInstruction(
434
}
435
return placeValue;
436
}
437
+ case "ObjectMethod":
438
case "FunctionExpression": {
439
constantPropagationImpl(value.loweredFunc.func, constants);
440
return null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-prop-to-object-method.expect.md
renamed
+4
-2
@@ -33,7 +33,7 @@ function Foo() {
33
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34
const x = {
35
foo() {
36
- return identity(CONSTANT);
36
+ return identity(1);
37
},
38
};
39
@@ -51,4 +51,6 @@ export const FIXTURE_ENTRYPOINT = {
51
};
52
53
```
54
-
\ No newline at end of file
54
+
55
+### Eval output
56
+(kind: ok) 1
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-prop-to-object-method.js
renamed
compiler/packages/sprout/src/SproutTodoFilter.ts
-1
@@ -515,7 +515,6 @@ const skipFilter = new Set([
515
"bug-jsx-memberexpr-tag-in-lambda",
516
"bug-invalid-code-when-bailout",
517
"component-syntax-ref-gating.flow",
518
- "bug-context-vars-in-object-method",
518
519
// 'react-forget-runtime' not yet supported
520
"flag-enable-emit-hook-guards",