Browse Source

Fix #2286 by printing an error correctly

gingerBill 2 years ago
parent
commit
5d397804f7
3 changed files with 12 additions and 1 deletions
  1. 3 0
      src/check_expr.cpp
  2. 6 0
      src/check_type.cpp
  3. 3 1
      src/llvm_backend_proc.cpp

+ 3 - 0
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);
 	}

+ 6 - 0
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) {

+ 3 - 1
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 = {};