From 982603aa5486d89672175f6198b031cef2bf758b Mon Sep 17 00:00:00 2001 From: Andrew Segavac Date: Tue, 19 Aug 2025 23:00:32 -0600 Subject: [PATCH] fix type system not resolving func args --- packages/boringlang/src/types/type_system.ts | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/boringlang/src/types/type_system.ts b/packages/boringlang/src/types/type_system.ts index 35e224c..8c160c8 100644 --- a/packages/boringlang/src/types/type_system.ts +++ b/packages/boringlang/src/types/type_system.ts @@ -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), + }; + }; }