Start typechecking generics

This commit is contained in:
nora 2023-11-06 20:41:49 +01:00
parent bf73203182
commit 01d4238269
15 changed files with 248 additions and 19 deletions

View file

@ -107,6 +107,7 @@ function resolveModule(
});
const scopes: string[] = [];
let tyParamScopes: string[] = [];
const popScope = (expected: string) => {
const popped = scopes.pop();
@ -130,6 +131,18 @@ function resolveModule(
}
}
for (let i = tyParamScopes.length - 1; i >= 0; i--) {
const candidate = tyParamScopes[i];
if (candidate === ident.name) {
return {
kind: "tyParam",
index: i,
name: ident.name,
};
}
}
const item = items.get(ident.name);
if (item !== undefined) {
return {
@ -214,6 +227,13 @@ function resolveModule(
defPath,
};
}
case "type": {
tyParamScopes = item.generics.map(({name}) => name);
const type = { ...superFoldItem(item, this) };
return type;
}
}
return { ...superFoldItem(item, this), defPath };