From: fennecdjay Date: Wed, 7 Dec 2022 13:14:36 +0000 (+0100) Subject: :art: improve foreach index defined error message X-Git-Tag: nightly~207^2~67 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f5a77a167a2b731792402c9a9869022fae303a2e;p=gwion.git :art: improve foreach index defined error message --- diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 2d7e9685..449f5a65 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -176,6 +176,7 @@ ANN static inline m_bool scan1_prim(const Env env, const Exp_Primary *prim) { return scan1_exp(env, prim->d.exp); if (prim->prim_type == ae_prim_hack) { if(env->func) env->func->weight = 1; // mark function has having gack + // we should use effects when typechecking for that return scan1_exp(env, prim->d.exp); } if (prim->prim_type == ae_prim_array && prim->d.array->exp) @@ -296,15 +297,14 @@ ANN static inline m_bool stmt_each_defined(const restrict Env env, ERR_B(stmt_self(stmt)->pos, _("foreach value '%s' is already defined"), s_name(stmt->sym)) if (stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->sym)) - ERR_B(stmt_self(stmt)->pos, _("foreach index '%s' is already defined"), + ERR_B(stmt->idx->pos, _("foreach index '%s' is already defined"), s_name(stmt->idx->sym)) return GW_OK; } ANN static inline m_bool shadow_err(const Env env, const Value v, const loc_t loc) { - if(env->scope->shadowing) - return GW_OK; + if(env->scope->shadowing) return GW_OK; gwerr_basic(_("shadowing a previously defined variable"), NULL, NULL, env->name, loc, 0); defined_here(v);