[test] Add failing test of incorrect typing of captured ref

The typer doesn't understand that it needs to ignore captured references ("read" 
refs are ok, but not "mutated" refs) to be conservative.
This commit is contained in:
Sathya Gunasekaran
2023-03-03 17:33:44 +00:00
parent ec2a179572
commit d24f3fdad9
2 changed files with 40 additions and 0 deletions
@@ -0,0 +1,31 @@
## Input
```javascript
function component(a) {
let x = { a };
let y = 1;
(function () {
y = x;
})();
mutate(y);
return y;
}
```
## Code
```javascript
function component(a) {
const x = { a: a };
(function () {
y = x;
})();
mutate(1);
return 1;
}
```
@@ -0,0 +1,9 @@
function component(a) {
let x = { a };
let y = 1;
(function () {
y = x;
})();
mutate(y);
return y;
}