aboutsummaryrefslogtreecommitdiff
path: root/src/checker.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-08-30 11:01:06 +0100
committergingerBill <bill@gingerbill.org>2024-08-30 11:01:06 +0100
commita4e865f90bd3a6f7e5ff004d691863827d0b9399 (patch)
tree02b2b6a024a89cdcfc80d57c0cd704b1acaf7887 /src/checker.cpp
parent9197a126fcb7042ede78c26178314342e23c58b6 (diff)
Fix #4166
Diffstat (limited to 'src/checker.cpp')
-rw-r--r--src/checker.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index d5234c01c..fa04911ac 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1786,7 +1786,9 @@ gb_internal void add_entity_use(CheckerContext *c, Ast *identifier, Entity *enti
entity->flags |= EntityFlag_Used;
if (entity_has_deferred_procedure(entity)) {
Entity *deferred = entity->Procedure.deferred_procedure.entity;
- add_entity_use(c, nullptr, deferred);
+ if (deferred != entity) {
+ add_entity_use(c, nullptr, deferred);
+ }
}
if (identifier == nullptr || identifier->kind != Ast_Ident) {
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;
}
+ 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)) {
error(src->token, "'%s' cannot be used with a polymorphic procedure", attribute);
continue;