From 5d397804f7c02a2a71a10dd3af2f59a1bb3b4a10 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 16 Jan 2023 13:22:37 +0000 Subject: [PATCH] Fix #2286 by printing an error correctly --- src/check_expr.cpp | 3 +++ src/check_type.cpp | 6 ++++++ src/llvm_backend_proc.cpp | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 608eb879b..b4b36a950 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -4898,6 +4898,9 @@ gb_internal bool is_type_normal_pointer(Type *ptr, Type **elem) { gb_internal bool is_type_valid_atomic_type(Type *elem) { elem = core_type(elem); + if (is_type_internally_pointer_like(elem)) { + return true; + } if (elem->kind == Type_BitSet) { elem = bit_set_to_int(elem); } diff --git a/src/check_type.cpp b/src/check_type.cpp index ad746514e..ec661134b 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1655,6 +1655,12 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para } else if (!ctx->no_polymorphic_errors) { // NOTE(bill): The type should be determined now and thus, no need to determine the type any more is_type_polymorphic_type = false; + Entity *proc_entity = entity_from_expr(op.expr); + if ((proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure)) { + if (is_type_polymorphic(proc_entity->type, false)) { + error(op.expr, "Cannot determine complete type of partial polymorphic procedure"); + } + } } } if (is_poly_name) { diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index b95fc7da6..822bae84e 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -68,7 +68,9 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i GB_ASSERT(entity != nullptr); GB_ASSERT(entity->kind == Entity_Procedure); if (!entity->Procedure.is_foreign) { - GB_ASSERT_MSG(entity->flags & EntityFlag_ProcBodyChecked, "%.*s :: %s (was parapoly: %d)", LIT(entity->token.string), type_to_string(entity->type), is_type_polymorphic(entity->type, true)); + if ((entity->flags & EntityFlag_ProcBodyChecked) == 0) { + GB_PANIC("%.*s :: %s (was parapoly: %d %d)", LIT(entity->token.string), type_to_string(entity->type), is_type_polymorphic(entity->type, true), is_type_polymorphic(entity->type, false)); + } } String link_name = {};