[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 committed 2023-03-03 17:33:44 +00:00
1 parent ec2a179572
commit d24f3fdad9
2 files changed
+40

No files matched your search

@@ -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;
}