From: Jérémie Astor Date: Wed, 6 May 2020 22:51:54 +0000 (+0200) Subject: :bug: Fix cyclic declaration X-Git-Tag: nightly~1642 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=ecbd49ebac0028e93b956e3b4a06c71345735eb6;p=gwion.git :bug: Fix cyclic declaration --- 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)) }