From 0f93a607bdbb7e77f75d3f9d10476d99c3e1b1cc Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 16 Aug 2019 16:02:35 +0200 Subject: [PATCH] :art: Improve check_exp_decl --- src/parse/check.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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) -- 2.43.0