aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-16 12:07:24 +0100
committergingerBill <bill@gingerbill.org>2021-06-16 12:07:24 +0100
commit41f2539484931cd73dfca36dcbdba01e954fc350 (patch)
treea76cd589c96065e2f2becb53004d564b0c6f5ff3 /src/check_decl.cpp
parent8f57bb07991930f242ec4ab4d9fb3a851a4e9662 (diff)
Improve logic for diverging procedures by checking if it terminates
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 1a87b57b8..583c4f133 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -1297,13 +1297,21 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
error(bs->close, "Missing return statement at the end of the procedure");
}
}
+ } else if (type->Proc.diverging) {
+ if (!check_is_terminating(body, str_lit(""))) {
+ if (token.kind == Token_Ident) {
+ error(bs->close, "Missing diverging call at the end of the procedure '%.*s'", LIT(token.string));
+ } else {
+ // NOTE(bill): Anonymous procedure (lambda)
+ error(bs->close, "Missing diverging call at the end of the procedure");
+ }
+ }
}
}
check_close_scope(ctx);
check_scope_usage(ctx->checker, ctx->scope);
-#if 1
if (decl->parent != nullptr) {
Scope *ps = decl->parent->scope;
if (ps->flags & (ScopeFlag_File & ScopeFlag_Pkg & ScopeFlag_Global)) {
@@ -1321,7 +1329,6 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
}
}
}
-#endif
}