From: Jérémie Astor Date: Thu, 28 May 2020 09:57:52 +0000 (+0200) Subject: :art: File level variable can't shadow global ones X-Git-Tag: nightly~1501 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=822124831826a1b3eaa1eda42e9c36cf1f2848f6;p=gwion.git :art: File level variable can't shadow global ones --- diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a3f65a2b..d09cbd71 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -77,7 +77,8 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { const Var_Decl var = list->self; CHECK_BB(isres(env, var->xid, exp_self(decl)->pos)) Type t = decl->type; - const Value former = nspc_lookup_value0(env->curr, var->xid); + const Value former = ((!env->class_def && !env->scope->depth) ? + nspc_lookup_value1 : nspc_lookup_value0)(env->curr, var->xid); if(former) ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), s_name(var->xid))