From b6da05ae90e5ba3865d31febd746aeeb64d69c52 Mon Sep 17 00:00:00 2001 From: ivanjermakov Date: Sat, 24 Aug 2024 02:16:41 +0200 Subject: [PATCH] Dedup reported type errors --- src/phase/type-unify.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/phase/type-unify.ts b/src/phase/type-unify.ts index 081e7a86..6edbbcae 100644 --- a/src/phase/type-unify.ts +++ b/src/phase/type-unify.ts @@ -16,7 +16,7 @@ import { unreachable } from '../util/todo' /** * Unify type bounds */ -export const unifyTypeBounds = (node: AstNode, ctx: Context): void => { +export const unifyTypeBounds = (node: AstNode, ctx: Context, report = true): void => { if (node.type) { unifyType(node.type) } @@ -85,7 +85,7 @@ export const unifyTypeBounds = (node: AstNode, ctx: Context): void => { break } case 'unary-expr': { - unifyTypeBounds(node.operand, ctx) + unifyTypeBounds(node.operand, ctx, false) switch (node.op.kind) { case 'call-op': { node.op.args.forEach(a => unifyTypeBounds(a, ctx)) @@ -157,7 +157,7 @@ export const unifyTypeBounds = (node: AstNode, ctx: Context): void => { break } } - if (node.type) { + if (node.type && report) { reportErrors(ctx, node) } } @@ -232,6 +232,7 @@ const unifyType = (type: InferredType): void => { break } Object.assign(type, ret) + unifyType(type) break } case 'identifier':