[λ] Fix mutatedDep collection in AnalyseFunctions

Make sure to check free variables as well for mutations. Not just object 
properties.
This commit is contained in:
Sathya Gunasekaran
2023-01-23 15:46:35 -05:00
parent ee3a88f20f
commit 19dd29707b
2 changed files with 14 additions and 7 deletions
@@ -85,6 +85,11 @@ function buildMutatedDeps(
continue;
}
mutatedDeps.push(dep);
} else if (
dep.identifier.name !== null &&
mutatedIds.has(dep.identifier.name)
) {
mutatedDeps.push(dep);
}
}
@@ -19,18 +19,20 @@ function component(a) {
```javascript
function component(a) {
const $ = React.useMemoCache();
const c_0 = $[0] !== a;
let y;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
if (c_0) {
y = function () {
m(x);
};
$[0] = y;
} else {
y = $[0];
}
const x = { a: a };
m(x);
const x = { a: a };
m(x);
$[0] = a;
$[1] = y;
} else {
y = $[1];
}
return y;
}