[λ] Add test for nested function declaration that captures a var

This commit is contained in:
Sathya Gunasekaran
2023-01-14 10:19:40 +00:00
parent 6af9c25300
commit ab6a1dbbd4
2 changed files with 67 additions and 0 deletions
@@ -0,0 +1,57 @@
## Input
```javascript
function component(a) {
let z = { a };
let x = function () {
function t() {
z;
}
t();
};
return x;
}
```
## Code
```javascript
function component(a) {
const $ = React.useMemoCache();
const c_0 = $[0] !== a;
let z;
if (c_0) {
z = {
a: a,
};
$[0] = a;
$[1] = z;
} else {
z = $[1];
}
const c_2 = $[2] !== z;
let x;
if (c_2) {
x = function () {
function t() {
z;
}
t();
};
$[2] = z;
$[3] = x;
} else {
x = $[3];
}
return x;
}
```
@@ -0,0 +1,10 @@
function component(a) {
let z = { a };
let x = function () {
function t() {
z;
}
t();
};
return x;
}