From: fennecdjay <fennecdjay@gmail.com>
Date: Wed, 7 Feb 2024 20:09:17 +0000 (+0100)
Subject: :fire: move const gen func
X-Git-Tag: nightly~109
X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=87e5f9013094b0675da0aff7ae90695461e2304f;p=gwion.git

:fire: move const gen func
---

diff --git a/src/parse/check.c b/src/parse/check.c
index 3291536f..0ed1c408 100644
--- a/src/parse/check.c
+++ b/src/parse/check.c
@@ -1871,21 +1871,6 @@ ANN static void fdef_const_generic_value(const Env env, const Type owner, const
   v->from->owner_class = owner;
 }
 
-ANN m_bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ) {
-  CHECK_OB(check_exp(env, targ->d.exp));
-  // check implicits?
-  const Type target = known_type(env, spec->td);
-  if(isa(targ->d.exp->type, target) < 0) {
-    char msg[256];
-    tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name);
-    gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0);
-    tcol_snprintf(msg, 255, "got {G+}%s{0}", targ->d.exp->type->name);
-    gwerr_secondary(msg, env->name, targ->d.exp->loc);
-    return GW_ERROR;
-  }
-  return GW_OK;
-}
-
 ANN static m_bool check_fdef_const_generic(const Env env, const Func_Def fdef) {
   const Tmpl *tmpl = fdef->base->tmpl;
   if(tmplarg_ntypes(tmpl->call) == tmpl->call->len) return GW_OK;
diff --git a/src/parse/template.c b/src/parse/template.c
index a3aeb904..f7cbe381 100644
--- a/src/parse/template.c
+++ b/src/parse/template.c
@@ -101,6 +101,21 @@ else      if(spec->tag.sym == targ->d.td->tag.sym) {
   }
 }
 
+ANN m_bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ) {
+  CHECK_OB(check_exp(env, targ->d.exp));
+  // check implicits?
+  const Type target = known_type(env, spec->td);
+  if(isa(targ->d.exp->type, target) < 0) {
+    char msg[256];
+    tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name);
+    gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0);
+    tcol_snprintf(msg, 255, "got {G+}%s{0}", targ->d.exp->type->name);
+    gwerr_secondary(msg, env->name, targ->d.exp->loc);
+    return GW_ERROR;
+  }
+  return GW_OK;
+}
+
 ANN m_bool template_push_types(const Env env, const Tmpl *tmpl) {
   nspc_push_type(env->gwion->mp, env->curr);
   if (tmpl->call) check_call(env, tmpl);