From ecbd49ebac0028e93b956e3b4a06c71345735eb6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 7 May 2020 00:51:54 +0200 Subject: [PATCH] :bug: Fix cyclic declaration --- src/parse/check.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/parse/check.c b/src/parse/check.c index c71144f1..ce74ee24 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -167,6 +167,14 @@ ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { ERR_O(td_pos(decl->td), _("can't find type")); { const Type t = get_type(decl->type); + if(env->class_def && !env->scope->depth){ + Type parent = t; + while(parent) { + if(parent == env->class_def && !GET_FLAG(decl->td, ref)) + ERR_O(decl->td->pos, "declaration cycle detected. (declare as ref?)") + parent = parent->e->parent; + } + } if(!GET_FLAG(t, check) && t->e->def) CHECK_BO(ensure_check(env, t)) } -- 2.43.0