From 64156ee719a17f973b43bebcce36cfe0661d570d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 3 Jul 2020 13:41:06 +0200 Subject: [PATCH] :art: Decl scoping (fix) --- src/parse/scan1.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 4247e7d0..3e9d0d53 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -60,15 +60,20 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) { return decl->type = t; } +static inline m_bool scan1_defined(const Env env, const Var_Decl var) { + if(((!env->class_def || env->scope->depth) ? nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->xid)) + ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), + s_name(var->xid)) + return GW_OK; +} + ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { Var_Decl_List list = decl->list; do { const Var_Decl var = list->self; CHECK_BB(isres(env, var->xid, exp_self(decl)->pos)) Type t = decl->type; - if((!env->class_def || env->scope->depth) ? (nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->xid)) - ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), - s_name(var->xid)) + CHECK_BB(scan1_defined(env, var)) if(var->array) { if(var->array->exp) { if(GET_FLAG(decl->td, ref)) -- 2.43.0