fix type system not resolving func args

This commit is contained in:
2025-08-19 23:00:32 -06:00
parent 05856f5d07
commit 982603aa54

View File

@@ -58,17 +58,8 @@ class TypeSystem {
while (true) { while (true) {
for (const comparison of this.comparisons) { for (const comparison of this.comparisons) {
// if already found, just update // if already found, just update
if (comparison.left.typeUsage === "UnknownTypeUsage" && this.result[comparison.left.name]) { comparison.left = this.resolveType(comparison.left);
foundUpdate = true; comparison.right = this.resolveType(comparison.right);
comparison.left = this.result[comparison.left.name];
}
if (
comparison.right.typeUsage === "UnknownTypeUsage" &&
this.result[comparison.right.name]
) {
foundUpdate = true;
comparison.right = this.result[comparison.right.name];
}
// equals // equals
if (comparison.operation.operation === "equals") { if (comparison.operation.operation === "equals") {
// solve left // solve left
@@ -177,4 +168,21 @@ class TypeSystem {
} }
return this.result; return this.result;
}; };
resolveType = (type: TypeUsage): TypeUsage => {
if (type.typeUsage === "UnknownTypeUsage") {
if (this.result[type.name]) {
return this.result[type.name];
}
return type;
}
if (type.typeUsage === "NamedTypeUsage") {
return type;
}
return {
typeUsage: "FunctionTypeUsage",
arguments: type.arguments.map((arg) => this.resolveType(arg)),
returnType: this.resolveType(type.returnType),
};
};
} }