From: fennecdjay Date: Mon, 24 Oct 2022 15:18:55 +0000 (+0200) Subject: :art: check trait defined X-Git-Tag: nightly~207^2~125 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3b2d3020ef4bc07387743777efbb92b93cea08f5;p=gwion.git :art: check trait defined --- diff --git a/src/parse/scan0.c b/src/parse/scan0.c index be407834..2ffa7034 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -450,9 +450,11 @@ ANN static m_bool _scan0_trait_def(const Env env, const Trait_Def pdef) { trait->loc = pdef->pos; trait->name = s_name(pdef->xid); trait->filename = env->name; - if(GET_FLAG(pdef, global)) - nspc_add_trait(env->global_nspc, pdef->xid, trait); - else nspc_add_trait(env->curr, pdef->xid, trait); + const bool global = GET_FLAG(pdef, global); + if(global) env_push_global(env); + CHECK_BB(scan0_defined(env, pdef->xid, pdef->pos)); + nspc_add_trait(env->curr, pdef->xid, trait); + if(global) env_pop(env, 0); Ast ast = pdef->body; if(!ast) return GW_OK; // ??? for(m_uint i = 0; i < ast->len; i++) {