@samitouri / QOS-React-1 / commits / b049c14bb3

Repro of hoisting bug

Adds a test case reproducing an issue with hoisting. This seems like a case where hoisting was incorrectly applied as this example doesn't require it

Lauren Tan committed Oct 20, 2023 at 11:34 UTC b049c14bb37965940aeeaa622d484981a2cf25a3
2 files changed +45
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting-nested-block-statements.expect.md new
+30
@@ -0,0 +1,30 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function hoisting(cond) {
6 + if (cond) {
7 + const x = 1;
8 + foo(x);
9 + }
10 +
11 + const x = 2;
12 + foo(x);
13 +}
14 +
15 +export const FIXTURE_ENTRYPOINT = {
16 + fn: hoisting,
17 + params: [false],
18 + isComponent: false,
19 +};
20 +
21 +```
22 +
23 +
24 +## Error
25 +
26 +```
27 +[ReactForget] Invariant: Expected value kind to be initialized at '8:6:8:7' (8:8)
28 +```
29 +
30 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting-nested-block-statements.js new
+15
@@ -0,0 +1,15 @@
1 +function hoisting(cond) {
2 + if (cond) {
3 + const x = 1;
4 + foo(x);
5 + }
6 +
7 + const x = 2;
8 + foo(x);
9 +}
10 +
11 +export const FIXTURE_ENTRYPOINT = {
12 + fn: hoisting,
13 + params: [false],
14 + isComponent: false,
15 +};