Repro for hoisting bug
I had added a repro for this earlier but hadn't realized it was due to const hoisting. Renaming this test to clarify what's causing the problem and to make it easier to find.
Joe Savona committed
Nov 15, 2023 at 16:34 UTC
b55ccb1b84e4fb7f15a092c05b6c159c397c9922
4 files changed
+25
-33
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-uninitialized-value-kind-with-function-expression-params.expect.md
deleted
-24
@@ -1,24 +0,0 @@
1
-
2
-## Input
3
-
4
-```javascript
5
-function Component(props) {
6
- // This `x` uses a context variable:
7
- const items = props.items.filter((x) => x != null);
8
- // and so does this one:
9
- const x = items.map((y) => y);
10
- // I think what's happening is that `x` is both a) used in a function expression and b) "reassigned",
11
- // meeting the criteria for context variables. Except that these are different instances of x.
12
- return x;
13
-}
14
-
15
-```
16
-
17
-
18
-## Error
19
-
20
-```
21
-[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$21 (8:8)
22
-```
23
-
24
-
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-uninitialized-value-kind-with-function-expression-params.js
deleted
-9
@@ -1,9 +0,0 @@
1
-function Component(props) {
2
- // This `x` uses a context variable:
3
- const items = props.items.filter((x) => x != null);
4
- // and so does this one:
5
- const x = items.map((y) => y);
6
- // I think what's happening is that `x` is both a) used in a function expression and b) "reassigned",
7
- // meeting the criteria for context variables. Except that these are different instances of x.
8
- return x;
9
-}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo.repro-hoisting-variable-collision.expect.md
new
+20
@@ -0,0 +1,20 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function Component(props) {
6
+ const items = props.items.map((x) => x);
7
+ const x = 42;
8
+ return [x, items];
9
+}
10
+
11
+```
12
+
13
+
14
+## Error
15
+
16
+```
17
+[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$13 (4:4)
18
+```
19
+
20
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo.repro-hoisting-variable-collision.js
new
+5
@@ -0,0 +1,5 @@
1
+function Component(props) {
2
+ const items = props.items.map((x) => x);
3
+ const x = 42;
4
+ return [x, items];
5
+}