:fire: remove env->context->error refs where possible
authorfennecdjay <fennecdjay@gmail.com>
Mon, 26 Feb 2024 18:23:27 +0000 (19:23 +0100)
committerfennecdjay <fennecdjay@gmail.com>
Mon, 26 Feb 2024 18:23:27 +0000 (19:23 +0100)
src/gwion.c
src/import/import_checker.c
src/lib/closure.c
src/lib/prim.c
src/parse/check_traits.c
src/parse/func_resolve_tmpl.c
src/parse/scan0.c
src/parse/type_decl.c
src/pass.c
src/plug.c

index 7ff6ac0a6787bf785fd853a2aa1f857a11c3704d..0138a719937eb2bf0857cf43a465251fa0659ec6 100644 (file)
@@ -213,7 +213,6 @@ ANN void env_warn(const Env env, const loc_t loc, const m_str fmt, ...) {
 }
 
 ANN void env_err(const Env env, const loc_t loc, const m_str fmt, ...) {
-//  if (env->context && env->context->error) return;
 #ifndef __FUZZING__
   va_list arg;
   va_start(arg, fmt);
index 6a4788739e8364935518740ff0d46ce16ad4426f..f288c401ef5e6005e3b7ae49e3bcdf5d7e94b4ed 100644 (file)
@@ -312,21 +312,8 @@ ANN static bool td_info_run(const Env env, struct td_info *info) {
     if (i) text_add(&info->fmt->ls->text, ",");
     TmplArg *targ = mp_vector_at(tl, TmplArg, i);
     if(targ->type == tmplarg_td) {
-      // we may need to stop errors
-      if(env->context) env->context->error = true;
-      const Type t = known_type(env, targ->d.td);
-      if(env->context) env->context->error = false;
-      if(t)
-        td_fullname(env, &info->fmt->ls->text, t);
-      else {
-        Exp* exp = td2exp(gwion->mp, targ->d.td);
-        if(traverse_exp(env, exp)) {
-          if(is_class(gwion, exp->type)) {
-            td_fullname(env, &info->fmt->ls->text, exp->type);
-            free_exp(gwion->mp, exp);
-          } else gwfmt_exp(info->fmt, exp);
-        } else GWION_ERR_B(targ->d.td->tag.loc, "invalid template argument");
-      }
+      DECL_B(const Type, t, = known_type(env, targ->d.td));
+      td_fullname(env, &info->fmt->ls->text, t);
     } else {
       Exp* exp = targ->d.exp;
       if(check_exp(env, targ->d.exp)) {
index 932bd8ea981cc3abd7aabf8037b908ea6fbed1a2..f118e76a04bc1350bec499cee47f1f1f50f34e0b 100644 (file)
@@ -467,13 +467,11 @@ static OP_CHECK(opck_fptr_cast) {
 }
 
 static void op_narg_err(const Env env, const Func_Def fdef, const loc_t loc) {
-  if (!env->context->error) {
-    gwerr_basic(_("invalid operator decay"),
-                _("Decayed operators take two arguments"), NULL, env->name, loc,
-                0);
-    if (fdef) defined_here(fdef->base->func->value_ref);
-    env_set_error(env, true);
-  }
+  gwerr_basic(_("invalid operator decay"),
+              _("Decayed operators take two arguments"), NULL, env->name, loc,
+            0);
+  if (fdef) defined_here(fdef->base->func->value_ref);
+  env_set_error(env, true);
 }
 static bool op_call_narg(const Env env, Exp* arg, const loc_t loc) {
   m_uint narg = 0;
index ebbe7a6d7e5ca4f05f80cf0db041a942a515860e..9d9b385c71680a6f7a8aab00f21087aafff7ff9b 100644 (file)
@@ -252,11 +252,9 @@ static GACK(gack_bool) {
 
 static OP_CHECK(bool2float) {
   struct Implicit *impl = (struct Implicit *)data;
-  if(!env->context->error) {
-    gwerr_basic("Can't implicitely cast {G+}bool{0} to {G+}float{0}", NULL, "Did you forget a cast?",
+  gwerr_basic("Can't implicitely cast {G+}bool{0} to {G+}float{0}", NULL, "Did you forget a cast?",
        env->name, impl->e->loc, 0);
-    env_set_error(env, true);
-  }
+  env_set_error(env, true);
   return env->gwion->type[et_error];
 }
 
index 883954e296fcafd3ad68e93d7475dc0e8b44b3c7..3576e14be91499e684a2b618bd0b31f04a0b1fc6 100644 (file)
@@ -145,11 +145,9 @@ ANN static bool request_fun(const Env env, const Type t,
   const Value parent = nspc_lookup_value1(env->global_nspc, request->base->tag.sym);
   if(parent) {
     const Value v = nspc_lookup_value1(env->curr, request->base->tag.sym);
-    if(!env->context->error) {
-      gwerr_basic_from("is missing {+G}global{0}", NULL, NULL, v->from, 0);
-      gwerr_secondary("from requested func", env->name, request->base->tag.loc);
-      env_set_error(env, true);
-    }
+    gwerr_basic_from("is missing {+G}global{0}", NULL, NULL, v->from, 0);
+    gwerr_secondary("from requested func", env->name, request->base->tag.loc);
+    env_set_error(env, true);
   } else gwerr_basic("missing requested function", NULL, NULL, env->name,
               request->base->tag.loc, 0);
   return false;
index 3bae63eaf235c2513981bf22bb309d1d3d0d4348..1251f45d61a9c1c81b37071b7ffce9134144e2f6 100644 (file)
@@ -43,7 +43,6 @@ tmpl_valid(const Env env, const Func_Def fdef, const m_str filename) {
 ANN static Func ensure_tmpl(const Env env, const Func_Def fdef,
                             Exp_Call *const exp, const m_str filename) {
   if (!tmpl_valid(env, fdef, filename)) return NULL;
-  if(env->context && env->context->error) return NULL;
   if (exp->args && !exp->args->type) return NULL;
   const Func f    = fdef->base->func;
   const Tmpl tmpl = {.list = fdef->base->tmpl->list, .call = exp->tmpl->call};
index 55ac3dc530447cf9df6e5e0ed903fda61edca4bc..fa1dc569fc47001a227f15fc949b22feae81ef70 100644 (file)
@@ -417,11 +417,8 @@ ANN static bool scan0_stmt_list(const Env env, Stmt_List l) {
           POISON_NODE(ok, env, stmt);
       }
     } else if (stmt->stmt_type == ae_stmt_spread) {
-      if(!spreadable(env)) {
+      if(!spreadable(env))
         ERR_OK_NODE(ok, stmt, stmt->loc, "spread statement outside of variadic environment");
-        stmt->poison = true;
-        env->context->error = true;
-      }
       if(!env->context->extend)
          env->context->extend = new_mp_vector(env->gwion->mp, Section, 0);
       if(!spread_tmpl(env, &stmt->d.stmt_spread))
index 73f047036cd5ebadfb8cfb8129311cef92ef29c0..75dc8fab2aa8236337086586ec9c763bf2309449 100644 (file)
@@ -108,8 +108,7 @@ ANN static Type resolve(const Env env, Type_Decl *td) {
   Type_Decl *last = td;
   while (last->next) last = last->next;
   DECL_O(const Type, base, = find(env, td));
-  const Context ctx = base->info->value->from->ctx;
-  if (ctx && ctx->error) ERR_O(td->tag.loc, _("type '%s' is invalid"), base->name);
+  if (base->error) ERR_O(td->tag.loc, _("type '%s' is invalid"), base->name);
   DECL_O(const Type, type, = find1(env, base, td));
   DECL_O(const Type, t,    = !td->ref ? type : ref(env, td));
   DECL_O(const Type, ret,  = !td->option ? t : option(env, td));
index f43d479e76c141d89bea0a04f2640737bfa62188..2cd453b11f0e625234f07d77f0e72c0230a1dc28 100644 (file)
 #define N_SCANPASS 4
 
 static bool typecheck_ast(const Env env, Ast *ast) {
-  if(!scan0_ast(env, ast))
-    env->context->error = true;
-  if(!scan1_ast(env, ast))
-    env->context->error = true;
-  if(!scan2_ast(env, ast))
-    env->context->error = true;
-  if(!check_ast(env, ast))
-    env->context->error = true;
-//  CHECK_B(traverse_ast(env, ast));
-//  if(env->scope->poison)env->context->error = true;
-  if(env->context->error)return false;
-  return true;
+  scan0_ast(env, ast);
+  scan1_ast(env, ast);
+  scan2_ast(env, ast);
+  check_ast(env, ast);
+  return !env->context->error;
 }
 
 static const m_str            default_passes_name[2] = {"check", "emit"};
index 7035eded2a88d6ef745729a90f400327262e478a..000068078517b6d300e6761b248ac308d9abc2d5 100644 (file)
@@ -228,8 +228,7 @@ ANN static bool _plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t
 ANN bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) {
   const Env env = gwion->env;
   if(!_plugin_ini(gwion, iname, loc)) {
-    if(gwion->env->context && !gwion->env->context->error)
-      env_err(env, loc, "%s: no such plugin\n", iname);
+    env_err(env, loc, "%s: no such plugin\n", iname);
     return false;
   }
   return true;