@samitouri / QOS-React-2 / commits / d24f3fdad9

[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.

Sathya Gunasekaran committed Mar 3, 2023 at 17:33 UTC d24f3fdad919cd261b9d7daec985f5c28639674c
2 files changed +40
compiler/forget/src/__tests__/fixtures/hir/_bug.capturing-reference-changes-type.expect.md new
+31
@@ -0,0 +1,31 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component(a) {
6 + let x = { a };
7 + let y = 1;
8 + (function () {
9 + y = x;
10 + })();
11 + mutate(y);
12 + return y;
13 +}
14 +
15 +```
16 +
17 +## Code
18 +
19 +```javascript
20 +function component(a) {
21 + const x = { a: a };
22 +
23 + (function () {
24 + y = x;
25 + })();
26 + mutate(1);
27 + return 1;
28 +}
29 +
30 +```
31 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/_bug.capturing-reference-changes-type.js new
+9
@@ -0,0 +1,9 @@
1 +function component(a) {
2 + let x = { a };
3 + let y = 1;
4 + (function () {
5 + y = x;
6 + })();
7 + mutate(y);
8 + return y;
9 +}