From 3a5439f60e5b577ce3be325627ec7f4d04cef35e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 16 Jun 2026 15:26:01 +0100 Subject: [PATCH] Compiler: Improve error propagation when all of the overloads have the same return values --- src/check_expr.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index a9c9f1fb0..0eca029d3 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7811,6 +7811,30 @@ gb_internal CallArgumentData check_call_arguments_proc_group(CheckerContext *c, } data.result_type = t_invalid; + if (procs.count > 0) { + Type *first_type = base_type(procs[0]->type); + GB_ASSERT(first_type->kind == Type_Proc); + Type *first_results = first_type->Proc.results; + bool all_the_same = true; + for (isize i = 1; i < procs.count; i++) { + Type *type = base_type(procs[i]->type); + if (type->kind != Type_Proc) { + all_the_same = false; + break; + } + Type *results = type->Proc.results; + if (!are_types_identical(first_results, results)) { + all_the_same = false; + break; + } + } + if (all_the_same) { + GB_ASSERT_MSG(is_type_tuple(first_results), "%s", type_to_string(first_results)); + data.result_type = first_results; + } + } + + } else if (valids.count > 1) { ERROR_BLOCK();