]> Nishi Git Mirror - gwion.git/commitdiff
:art: File level variable can't shadow global ones
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 28 May 2020 09:57:52 +0000 (11:57 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 28 May 2020 09:57:52 +0000 (11:57 +0200)
src/parse/scan1.c

index a3f65a2b095896592e863213d36e351ceca61dac..d09cbd71ec82002f21b3050c754113ed2b5166d8 100644 (file)
@@ -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))