From ca70eb23356b698fc89fd2053e6a2b4cfe7d792e Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sun, 26 May 2019 21:21:48 +0200 Subject: [PATCH] :bug: Template Fixes :smile: --- src/emit/emit.c | 9 +++++++++ src/parse/scan1.c | 3 +++ src/parse/template.c | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 4b9b64e7..d64392d2 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1664,6 +1664,13 @@ ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def func_def return GW_OK; } +ANN static m_bool tmpl_rettype(const Emitter emit, const Func_Def func_def) { + CHECK_BB(template_push_types(emit->env, func_def->base->tmpl)) + const m_bool ret = emit_parent_inner(emit, func_def->base->ret_type->e->def); + nspc_pop_type(emit->gwion->mp, emit->env->curr); + return ret; +} + ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) { const Func func = get_func(emit->env, func_def); const Func former = emit->env->func; @@ -1673,6 +1680,8 @@ ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) { UNSET_FLAG(func_def, template); return GW_OK; } + if(GET_FLAG(func_def->base->ret_type, template) && !GET_FLAG(func_def->base->ret_type, emit)) + CHECK_BB(tmpl_rettype(emit, func_def)) if(SAFE_FLAG(emit->env->class_def, builtin) && GET_FLAG(emit->env->class_def, template)) return GW_OK; if(!emit->env->class_def && !GET_FLAG(func_def, global) && !func_def->base->tmpl && !emit->env->scope->depth) diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 4fa0b6be..bad13338 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -15,6 +15,9 @@ ANN static m_bool scan1_stmt_list(const Env env, Stmt_List list); ANN static m_bool scan1_stmt(const Env env, Stmt stmt); ANN static Type void_type(const Env env, const Type_Decl* td) { +// could be more precise + if(SAFE_FLAG(env->class_def, template) && td->types) + return t_undefined; const Type t = known_type(env, td); CHECK_OO(t) if(t->size) diff --git a/src/parse/template.c b/src/parse/template.c index 5be9e0a3..b1e7d178 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -177,7 +177,8 @@ ANN Type scan_type(const Env env, const Type t, const Type_Decl* type) { SET_FLAG(a->base.type, dtor); ADD_REF(t->nspc->dtor) } - nspc_add_type(t->e->owner, insert_symbol(a->base.type->name), a->base.type); +// nspc_add_type(t->e->owner, insert_symbol(a->base.type->name), a->base.type); + map_set(&t->e->owner->info->type->map, insert_symbol(a->base.type->name), a->base.type); return a->base.type; } else if(type->types) ERR_O(type->xid->pos, -- 2.43.0