@samitouri / QOS-React / commits / 1b6afa1879

Repro for uninitialized value due to shadowed function name

Joe Savona committed Mar 21, 2024 at 14:11 UTC 1b6afa187923bb080084935e71ab99ece7767a82
2 files changed +40
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-repro-named-function-with-shadowed-local-same-name.expect.md new
+30
@@ -0,0 +1,30 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function Component(props) {
6 + function hasErrors() {
7 + let hasErrors = false;
8 + if (props.items == null) {
9 + hasErrors = true;
10 + }
11 + return hasErrors;
12 + }
13 + return hasErrors();
14 +}
15 +
16 +```
17 +
18 +
19 +## Error
20 +
21 +```
22 + 7 | return hasErrors;
23 + 8 | }
24 +> 9 | return hasErrors();
25 + | ^^^^^^^^^ [ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. hasErrors_0$16 (9:9)
26 + 10 | }
27 + 11 |
28 +```
29 +
30 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-repro-named-function-with-shadowed-local-same-name.js new
+10
@@ -0,0 +1,10 @@
1 +function Component(props) {
2 + function hasErrors() {
3 + let hasErrors = false;
4 + if (props.items == null) {
5 + hasErrors = true;
6 + }
7 + return hasErrors;
8 + }
9 + return hasErrors();
10 +}