@samitouri / QOS-React-2 / commits / 4a793bb86e

[hoisting] Add more repros for hoisting bugs

Lauren Tan committed Nov 2, 2023 at 11:01 UTC 4a793bb86e6aa8c27b7dcba5783a2f8dbb5b68d0
4 files changed +70
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting.expect.md new
+26
@@ -0,0 +1,26 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function Component(props) {
6 + const wat = () => {
7 + const pathname = "wat";
8 + pathname;
9 + };
10 +
11 + const pathname = props.wat;
12 + const deeplinkItemId = pathname ? itemID : null;
13 +
14 + return <button onClick={() => wat()}>{deeplinkItemId}</button>;
15 +}
16 +
17 +```
18 +
19 +
20 +## Error
21 +
22 +```
23 +[ReactForget] Invariant: Expected value kind to be initialized at '8:25:8:33' (8:8)
24 +```
25 +
26 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting.js new
+11
@@ -0,0 +1,11 @@
1 +function Component(props) {
2 + const wat = () => {
3 + const pathname = "wat";
4 + pathname;
5 + };
6 +
7 + const pathname = props.wat;
8 + const deeplinkItemId = pathname ? itemID : null;
9 +
10 + return <button onClick={() => wat()}>{deeplinkItemId}</button>;
11 +}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting2.expect.md new
+24
@@ -0,0 +1,24 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function Component() {
6 + useRunOnceDuringRender(() => {
7 + const handler = () => {
8 + return () => {
9 + detachHandler(handler);
10 + };
11 + };
12 + });
13 +}
14 +
15 +```
16 +
17 +
18 +## Error
19 +
20 +```
21 +[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
22 +```
23 +
24 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting2.js new
+9
@@ -0,0 +1,9 @@
1 +function Component() {
2 + useRunOnceDuringRender(() => {
3 + const handler = () => {
4 + return () => {
5 + detachHandler(handler);
6 + };
7 + };
8 + });
9 +}