fix type system not resolving func args
This commit is contained in:
@@ -58,17 +58,8 @@ class TypeSystem {
|
||||
while (true) {
|
||||
for (const comparison of this.comparisons) {
|
||||
// if already found, just update
|
||||
if (comparison.left.typeUsage === "UnknownTypeUsage" && this.result[comparison.left.name]) {
|
||||
foundUpdate = true;
|
||||
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];
|
||||
}
|
||||
comparison.left = this.resolveType(comparison.left);
|
||||
comparison.right = this.resolveType(comparison.right);
|
||||
// equals
|
||||
if (comparison.operation.operation === "equals") {
|
||||
// solve left
|
||||
@@ -177,4 +168,21 @@ class TypeSystem {
|
||||
}
|
||||
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),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user