From 8987b73104da44788770499cf5f21fb5f66150da Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 2 Feb 2023 08:58:49 +0100 Subject: [PATCH] :art: improve tmpl_arg_match --- src/parse/check.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index 66ea0cfa..681b255d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -544,10 +544,13 @@ ANN static Type_Decl* mk_td(const Env env, Type_Decl *td, ANN static Type tmpl_arg_match(const Env env, const Symbol xid, const Symbol tgt, const Type t) { if (xid == tgt) return t; - if(!tflag(t, tflag_cdef)) return NULL; - const uint32_t len = mp_vector_len(t->info->cdef->base.tmpl->list); + Tmpl *tmpl = tflag(t, tflag_cdef) ? t->info->cdef->base.tmpl + : tflag(t, tflag_udef) ? t->info->udef->tmpl + : NULL; + if (!tmpl) return NULL; + const uint32_t len = mp_vector_len(tmpl->list); for(uint32_t i = 0; i < len; i++) { - Specialized *spec = mp_vector_at(t->info->cdef->base.tmpl->list, Specialized, i); + Specialized *spec = mp_vector_at(tmpl->list, Specialized, i); const Type base = nspc_lookup_type1(t->nspc, spec->xid); const Type t = tmpl_arg_match(env, xid, spec->xid, base); if(t) return t; -- 2.43.0