Repro for bug with incorrectly using context variables when name overlaps

This commit is contained in:
Joe Savona
2023-11-01 17:42:14 -07:00
parent ab0f698585
commit 956c1ee7e2
2 changed files with 33 additions and 0 deletions
@@ -0,0 +1,24 @@
## Input
```javascript
function Component(props) {
// This `x` uses a context variable:
const items = props.items.filter((x) => x != null);
// and so does this one:
const x = items.map((y) => y);
// I think what's happening is that `x` is both a) used in a function expression and b) "reassigned",
// meeting the criteria for context variables. Except that these are different instances of x.
return x;
}
```
## Error
```
[ReactForget] Invariant: Expected value kind to be initialized at '8:9:8:10' (8:8)
```
@@ -0,0 +1,9 @@
function Component(props) {
// This `x` uses a context variable:
const items = props.items.filter((x) => x != null);
// and so does this one:
const x = items.map((y) => y);
// I think what's happening is that `x` is both a) used in a function expression and b) "reassigned",
// meeting the criteria for context variables. Except that these are different instances of x.
return x;
}