Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-y committed Sep 2, 2024
1 parent d34b5de commit 79c0951
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/semantics/check-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/semantics/resolution/get-call-fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 79c0951

Please sign in to comment.