[repro] repro for ContextVariable bug (ObjectMethod)
Found from eslint validator on www after doing a local sync + RunForget test of #2432 P898168203 > New Errors: > no-undef:'VARIABLE_NAME' is not defined.
Mofei Zhang committed
Dec 6, 2023 at 13:20 UTC
d3e84d4dffdbcea8d2d8371d056f1cb670a045d5
3 files changed
+71
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.expect.md
new
+54
@@ -0,0 +1,54 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+import { identity } from "shared-runtime";
6
+
7
+function Foo() {
8
+ const CONSTANT = 1;
9
+ const x = {
10
+ foo() {
11
+ return identity(CONSTANT);
12
+ },
13
+ };
14
+ return x.foo();
15
+}
16
+
17
+export const FIXTURE_ENTRYPOINT = {
18
+ fn: Foo,
19
+ params: [{}],
20
+};
21
+
22
+```
23
+
24
+## Code
25
+
26
+```javascript
27
+import { unstable_useMemoCache as useMemoCache } from "react";
28
+import { identity } from "shared-runtime";
29
+
30
+function Foo() {
31
+ const $ = useMemoCache(1);
32
+ let t0;
33
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
34
+ const x = {
35
+ foo() {
36
+ return identity(CONSTANT);
37
+ },
38
+ };
39
+
40
+ t0 = x.foo();
41
+ $[0] = t0;
42
+ } else {
43
+ t0 = $[0];
44
+ }
45
+ return t0;
46
+}
47
+
48
+export const FIXTURE_ENTRYPOINT = {
49
+ fn: Foo,
50
+ params: [{}],
51
+};
52
+
53
+```
54
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-context-vars-in-object-method.js
new
+16
@@ -0,0 +1,16 @@
1
+import { identity } from "shared-runtime";
2
+
3
+function Foo() {
4
+ const CONSTANT = 1;
5
+ const x = {
6
+ foo() {
7
+ return identity(CONSTANT);
8
+ },
9
+ };
10
+ return x.foo();
11
+}
12
+
13
+export const FIXTURE_ENTRYPOINT = {
14
+ fn: Foo,
15
+ params: [{}],
16
+};
compiler/packages/sprout/src/SproutTodoFilter.ts
+1
@@ -515,6 +515,7 @@ 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",
519
520
// 'react-forget-runtime' not yet supported
521
"flag-enable-emit-hook-guards",