[repro] add fixture repro for destructuring bug
Mofei Zhang committed
Jan 18, 2024 at 18:29 UTC
f88e7fe4120b8355ec290acea54036874edec641
3 files changed
+61
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-destructuring-same-property-identifier-names.expect.md
new
+51
@@ -0,0 +1,51 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function Component(props) {
6
+ const {
7
+ x: { destructured },
8
+ sameName: renamed,
9
+ } = props;
10
+ const sameName = foo(destructured);
11
+
12
+ return [sameName, renamed];
13
+}
14
+
15
+```
16
+
17
+## Code
18
+
19
+```javascript
20
+import { unstable_useMemoCache as useMemoCache } from "react";
21
+function Component(props) {
22
+ const $ = useMemoCache(6);
23
+ let sameName;
24
+ let renamed;
25
+ if ($[0] !== props) {
26
+ const { x: t20, sameName: t32 } = props;
27
+ renamed = t32;
28
+ sameName = foo(destructured);
29
+ $[0] = props;
30
+ $[1] = sameName;
31
+ $[2] = renamed;
32
+ } else {
33
+ sameName = $[1];
34
+ renamed = $[2];
35
+ }
36
+
37
+ const t0 = sameName;
38
+ let t1;
39
+ if ($[3] !== t0 || $[4] !== renamed) {
40
+ t1 = [t0, renamed];
41
+ $[3] = t0;
42
+ $[4] = renamed;
43
+ $[5] = t1;
44
+ } else {
45
+ t1 = $[5];
46
+ }
47
+ return t1;
48
+}
49
+
50
+```
51
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-destructuring-same-property-identifier-names.js
new
+9
@@ -0,0 +1,9 @@
1
+function Component(props) {
2
+ const {
3
+ x: { destructured },
4
+ sameName: renamed,
5
+ } = props;
6
+ const sameName = foo(destructured);
7
+
8
+ return [sameName, renamed];
9
+}
compiler/packages/sprout/src/SproutTodoFilter.ts
+1
@@ -516,6 +516,7 @@ const skipFilter = new Set([
516
"bug-jsx-memberexpr-tag-in-lambda",
517
"bug-invalid-code-when-bailout",
518
"component-syntax-ref-gating.flow",
519
+ "bug-destructuring-same-property-identifier-names",
520
521
// 'react-forget-runtime' not yet supported
522
"flag-enable-emit-hook-guards",