From b64407915db6af48202e7502f59351c6ee26d148 Mon Sep 17 00:00:00 2001 From: corley Date: Fri, 24 Jul 2026 01:13:03 +0300 Subject: [PATCH] fixes spurious no_alias errors during polymorphic overload resolution --- src/check_type.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index 01bc16983..be06ca108 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2228,9 +2228,13 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para } if (p->flags&FieldFlag_no_alias) { - bool ok = is_type_internally_pointer_like(type); - if (!ok) { - error(name, "'#no_alias' can only be applied pointer-like type parameters"); + // If type == t_invalid, we either already errored (and erroring again here is just log + // noise) or we are rejecting a polymorphic proc group overload candidate. + // If no_polymorphic_errors is set, we are speculatively checking a candidate and + // erroring+stripping is premature: the chosen candidate will be re-checked with errors enabled, + // so a true error isn't lost. + if (type != t_invalid && !is_type_internally_pointer_like(type) && !ctx->no_polymorphic_errors) { + error(name, "'#no_alias' can only be applied to pointer-like type parameters"); p->flags &= ~FieldFlag_no_alias; // Remove the flag } }