This commit is contained in:
gingerBill
2024-08-30 11:01:06 +01:00
parent 9197a126fc
commit a4e865f90b
+7
View File
@@ -1786,8 +1786,10 @@ gb_internal void add_entity_use(CheckerContext *c, Ast *identifier, Entity *enti
entity->flags |= EntityFlag_Used; entity->flags |= EntityFlag_Used;
if (entity_has_deferred_procedure(entity)) { if (entity_has_deferred_procedure(entity)) {
Entity *deferred = entity->Procedure.deferred_procedure.entity; Entity *deferred = entity->Procedure.deferred_procedure.entity;
if (deferred != entity) {
add_entity_use(c, nullptr, deferred); add_entity_use(c, nullptr, deferred);
} }
}
if (identifier == nullptr || identifier->kind != Ast_Ident) { if (identifier == nullptr || identifier->kind != Ast_Ident) {
return; return;
} }
@@ -6114,6 +6116,11 @@ gb_internal void check_deferred_procedures(Checker *c) {
case DeferredProcedure_in_out_by_ptr: attribute = "deferred_in_out_by_ptr"; break; case DeferredProcedure_in_out_by_ptr: attribute = "deferred_in_out_by_ptr"; break;
} }
if (src == dst) {
error(src->token, "'%.*s' cannot be used as its own %s", LIT(dst->token.string), attribute);
continue;
}
if (is_type_polymorphic(src->type) || is_type_polymorphic(dst->type)) { if (is_type_polymorphic(src->type) || is_type_polymorphic(dst->type)) {
error(src->token, "'%s' cannot be used with a polymorphic procedure", attribute); error(src->token, "'%s' cannot be used with a polymorphic procedure", attribute);
continue; continue;