@samitouri / QOS-React-2 / commits / 956c1ee7e2

Repro for bug with incorrectly using context variables when name overlaps

Joe Savona committed Nov 1, 2023 at 17:42 UTC 956c1ee7e22dfd401f3e9dfa3d38989c6c74d670
2 files changed +33
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-uninitialized-value-kind-with-function-expression-params.expect.md new
+24
@@ -0,0 +1,24 @@
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: Expected value kind to be initialized at '8:9:8:10' (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 new
+9
@@ -0,0 +1,9 @@
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 +}