JS: Add type-tracking test

This commit is contained in:
Asger F
2024-02-29 09:59:44 +01:00
parent ca1a27dc75
commit 7cd84c8f0a
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| summarize.js:30:14:30:26 | // track: obj | Failed to track obj here. |
| summarize.js:33:14:33:26 | // track: obj | Failed to track obj here. |

View File

@@ -0,0 +1,33 @@
import 'dummy';
function identity(x) {
return x;
}
function load(x) {
return x.loadProp;
}
function store(x) {
return { storeProp: x };
}
function loadStore(x) {
return { storeProp: x.loadProp };
}
identity({});
load({});
store({});
loadStore({});
const obj = {}; // name: obj
let x = identity(obj);
x; // track: obj
x = load({ loadProp: obj });
x; // track: obj
x = store(obj);
x.storeProp; // track: obj
x = loadStore({ loadProp: obj });
x.storeProp; // track: obj