diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.expect.md new file mode 100644 index 0000000000..6e16d5eceb --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.expect.md @@ -0,0 +1,54 @@ + +## Input + +```javascript +import { identity } from "shared-runtime"; + +function Foo() { + const CONSTANT = 1; + const x = { + foo() { + return identity(CONSTANT); + }, + }; + return x.foo(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [{}], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +import { identity } from "shared-runtime"; + +function Foo() { + const $ = useMemoCache(1); + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + const x = { + foo() { + return identity(CONSTANT); + }, + }; + + t0 = x.foo(); + $[0] = t0; + } else { + t0 = $[0]; + } + return t0; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [{}], +}; + +``` + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.js new file mode 100644 index 0000000000..1c53747fe8 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.js @@ -0,0 +1,16 @@ +import { identity } from "shared-runtime"; + +function Foo() { + const CONSTANT = 1; + const x = { + foo() { + return identity(CONSTANT); + }, + }; + return x.foo(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [{}], +}; diff --git a/compiler/packages/sprout/src/SproutTodoFilter.ts b/compiler/packages/sprout/src/SproutTodoFilter.ts index 7990cc08ea..62f8ce2d88 100644 --- a/compiler/packages/sprout/src/SproutTodoFilter.ts +++ b/compiler/packages/sprout/src/SproutTodoFilter.ts @@ -515,6 +515,7 @@ const skipFilter = new Set([ "bug-jsx-memberexpr-tag-in-lambda", "bug-invalid-code-when-bailout", "component-syntax-ref-gating.flow", + "bug-context-vars-in-object-method", // 'react-forget-runtime' not yet supported "flag-enable-emit-hook-guards",