[test] Add test for broken lambda capturing

SSA redefines context refs which breaks our inference. The correct fix here is 
to not overwrite context refs in EnterSSA.
This commit is contained in:
Sathya Gunasekaran committed 2023-02-10 17:59:59 +00:00
1 parent b56f413e99
commit 7277897405
2 files changed
+49

No files matched your search

@@ -0,0 +1,40 @@
## Input
```javascript
function component(a) {
let x = { a };
let y;
(function () {
y = x;
})();
mutate(y);
return y;
}
```
## Code
```javascript
function component(a) {
const $ = React.unstable_useMemoCache();
const c_0 = $[0] !== a;
let x;
if (c_0) {
x = { a: a };
$[0] = a;
$[1] = x;
} else {
x = $[1];
}
const y = undefined;
(function () {
y = x;
})();
mutate(y);
return y;
}
```
@@ -0,0 +1,9 @@
function component(a) {
let x = { a };
let y;
(function () {
y = x;
})();
mutate(y);
return y;
}