From 822124831826a1b3eaa1eda42e9c36cf1f2848f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 28 May 2020 11:57:52 +0200 Subject: [PATCH] :art: File level variable can't shadow global ones --- src/parse/scan1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) -- 2.43.0