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;