From a74e294edcac61adf41ad542df14b0e681100877 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 3 Apr 2022 23:52:44 +0200 Subject: [PATCH] Fix nested templates/typedefs --- src/env/envset.c | 8 ++++---- src/lib/tmpl_info.c | 1 + src/parse/template.c | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/env/envset.c b/src/env/envset.c index 6e03141b..ac0d37b1 100644 --- a/src/env/envset.c +++ b/src/env/envset.c @@ -43,8 +43,8 @@ ANN2(1, 3) m_bool envset_push(struct EnvSet *es, const Type t, const Nspc nspc) { if (t) { check(es, t); - if(es->run && type_global(es->env, t)) - env_push_global(es->env); +// if(es->run && type_global(es->env, t)) +// env_push_global(es->env); return es->run ? push(es, t) : GW_OK; } if (nspc != es->env->curr) { @@ -68,8 +68,8 @@ ANN2(1) static void _envset_pop(struct EnvSet *es, const Type t) { ANN2(1) void envset_pop(struct EnvSet *es, const Type t) { _envset_pop(es, t); - if(t && type_global(es->env, t)) - env_pop(es->env, es->scope); +// if(t && type_global(es->env, t)) +// env_pop(es->env, es->scope); if (es->_ctx) es->env->context = es->_ctx; if (es->_filename) es->env->name = es->_filename; } diff --git a/src/lib/tmpl_info.c b/src/lib/tmpl_info.c index 4b294af5..65705889 100644 --- a/src/lib/tmpl_info.c +++ b/src/lib/tmpl_info.c @@ -47,6 +47,7 @@ ANN static ssize_t template_size(const Env env, struct tmpl_info *info) { const size_t tmpl_sz = tmpl_set(info, str); const m_str base = type2str(env->gwion, info->base, info->td->pos); return tmpl_sz + tmpl_set(info, base) + 4; +// return tmpl_sz + tmpl_set(info, info->base->name) + 4; } ANEW ANN static Symbol _template_id(const Env env, struct tmpl_info *const info, diff --git a/src/parse/template.c b/src/parse/template.c index eaf5b67b..69d3d53c 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -119,9 +119,11 @@ ANN static Type _scan_type(const Env env, const Type t, Type_Decl *td) { if(!td->types) { const Type new_type = nspc_lookup_type1(env->curr, td->xid); Type_Decl *new_td = type2td(env->gwion, new_type, td->pos); - if(!new_td->types) + Type_Decl *d = new_td; + while(d->next) d = d->next; + if(!d->types) ERR_N(td->pos, _("you must provide template types for type '%s' !!!"), t->name); - const Type ret = _scan_type(env, t, new_td); + const Type ret = _scan_type(env, t, d); free_type_decl(env->gwion->mp, new_td); return ret; } -- 2.43.0