From: Jérémie Astor Date: Sat, 9 May 2020 19:24:41 +0000 (+0200) Subject: :art: Check inheritance dependancy X-Git-Tag: nightly~1614 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=1e42857dad479bc99f4a6c8e014d1fd1b0796cf9;p=gwion.git :art: Check inheritance dependancy --- diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 0af9b5b3..f4b6ef9d 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -313,13 +313,24 @@ ANN static void cdef_flag(const Class_Def cdef, const Type t) { SET_FLAG(t, typedef); } +ANN static Type get_parent_base(const Env env, Type_Decl *td) { + DECL_OO(const Type, t, = find_type(env, td)) + Type owner = env->class_def; + while(owner) { + if(t == owner) + ERR_O(td_pos(td), _("'%s' as parent inside itself\n."), owner->name); + owner = owner->e->owner_class; + } + return t; +} + ANN static Type get_parent(const Env env, const Class_Def cdef) { if(GET_FLAG(cdef, struct)) return NULL; if(!cdef->base.ext) return env->gwion->type[et_object]; if(tmpl_base(cdef->base.tmpl)) - return nspc_lookup_type1(env->curr, cdef->base.ext->xid); + return get_parent_base(env, cdef->base.ext); if(cdef->base.tmpl) template_push_types(env, cdef->base.tmpl); const Type t = known_type(env, cdef->base.ext);