From: fennecdjay Date: Fri, 16 Aug 2019 14:02:35 +0000 (+0200) Subject: :art: Improve check_exp_decl X-Git-Tag: nightly~2276 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0f93a607bdbb7e77f75d3f9d10476d99c3e1b1cc;p=gwion.git :art: Improve check_exp_decl --- diff --git a/src/parse/check.c b/src/parse/check.c index 818907dc..9c2ef81d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -89,12 +89,16 @@ ANN Type check_td(const Env env, Type_Decl *td) { return t; } -ANN static Type no_xid(const Env env, const Exp_Decl* decl) { - DECL_OO(const Type, t, = check_td(env, decl->td)) - ((Exp_Decl*)decl)->type = NULL; +ANN static inline void clear_decl(const Env env, const Exp_Decl *decl) { Var_Decl_List list = decl->list; - do nspc_add_value(env->curr, list->self->xid, NULL); + do scope_add(env->curr->info->value, (vtype)list->self->xid, (vtype)NULL); while((list = list->next)); +} + +ANN static Type no_xid(const Env env, const Exp_Decl *decl) { + DECL_OO(const Type, t, = check_td(env, decl->td)) + ((Exp_Decl*)decl)->type = NULL; + clear_decl(env, decl); CHECK_BO(traverse_decl(env, decl)) return decl->type; } @@ -105,6 +109,7 @@ ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { if(!decl->td->xid) return no_xid(env, decl); if(decl->td->xid->xid == insert_symbol("auto")) { // should be better + clear_decl(env, decl); CHECK_BO(scan1_exp(env, exp_self(decl))) CHECK_BO(scan2_exp(env, exp_self(decl))) if(decl->type == t_auto)