From: Jérémie Astor Date: Tue, 30 Jun 2020 21:28:43 +0000 (+0200) Subject: :art: Clean scan1_decl X-Git-Tag: nightly~1457 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b47c2c518bce736b74a9cd40d91e870694c017dd;p=gwion.git :art: Clean scan1_decl --- diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 115f19cd..ec11950d 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -66,9 +66,7 @@ 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 = ((!env->class_def && !env->scope->depth) ? - nspc_lookup_value1 : nspc_lookup_value0)(env->curr, var->xid); - if(former) + if(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)) if(var->array) { @@ -85,7 +83,7 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { else ERR_B(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name) } - const Value v = var->value = former ?: new_value(env->gwion->mp, t, s_name(var->xid)); + const Value v = var->value = new_value(env->gwion->mp, t, s_name(var->xid)); if(SAFE_FLAG(env->class_def, struct) && !GET_FLAG(decl->td, static)) { v->from->offset = env->class_def->size; env->class_def->size += t->size;