From f5a77a167a2b731792402c9a9869022fae303a2e Mon Sep 17 00:00:00 2001
From: fennecdjay <fennecdjay@gmail.com>
Date: Wed, 7 Dec 2022 14:14:36 +0100
Subject: [PATCH] :art: improve foreach index defined error message

---
 src/parse/scan1.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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);
-- 
2.43.0