From 79c09513dd1f2e38ab76465c227ab1a823e89195 Mon Sep 17 00:00:00 2001 From: Drew Youngwerth Date: Sun, 1 Sep 2024 18:56:09 -0700 Subject: [PATCH] Bugfix --- src/semantics/check-types.ts | 6 +++--- src/semantics/resolution/get-call-fn.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/semantics/check-types.ts b/src/semantics/check-types.ts index c5863f6a..b35818d2 100644 --- a/src/semantics/check-types.ts +++ b/src/semantics/check-types.ts @@ -186,15 +186,15 @@ const checkFnTypes = (fn: Fn): Fn => { checkTypes(fn.returnTypeExpr); } - fn.body = checkTypes(fn.body); - const inferredReturnType = fn.inferredReturnType; - if (!fn.returnType) { throw new Error( `Unable to determine return type for ${fn.name} at ${fn.location}` ); } + checkTypes(fn.body); + const inferredReturnType = fn.inferredReturnType; + if ( inferredReturnType && !typesAreEquivalent(inferredReturnType, fn.returnType) diff --git a/src/semantics/resolution/get-call-fn.ts b/src/semantics/resolution/get-call-fn.ts index 4687c82e..41e3702d 100644 --- a/src/semantics/resolution/get-call-fn.ts +++ b/src/semantics/resolution/get-call-fn.ts @@ -11,9 +11,7 @@ export const getCallFn = (call: Call): Fn | undefined => { const arg = call.argAt(index); if (!arg) return false; const argType = getExprType(arg); - if (!argType) { - throw new Error(`Could not determine type for ${arg}`); - } + if (!argType) return false; const argLabel = getExprLabel(arg); const labelsMatch = p.label === argLabel; return typesAreEquivalent(argType, p.type!) && labelsMatch;