From: Jérémie Astor Date: Tue, 12 May 2020 16:17:14 +0000 (+0200) Subject: :art: Improve fptr template parsing X-Git-Tag: nightly~1575 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d40f3855460028f089840f8ece0a057785543f3f;p=gwion.git :art: Improve fptr template parsing --- diff --git a/src/parse/check.c b/src/parse/check.c index e29b959f..9270a82d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -581,7 +581,8 @@ ANN Func find_template_match(const Env env, const Value value, const Exp_Call* e return f; Type t = value->from->owner_class; while(t && t->nspc) { - const Value v = nspc_lookup_value0(t->nspc, value->d.func_ref->def->base->xid); + Func_Def fdef = value->d.func_ref ? value->d.func_ref->def : value->type->e->d.func->def; + const Value v = nspc_lookup_value0(t->nspc, fdef->base->xid); if(!v) goto next; const Func f = _find_template_match(env, v, exp); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 6bac630a..8a6bbf32 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -322,10 +322,7 @@ ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) { CHECK_OB((fdef->base->ret_type = scan1_type(env, fdef->base->td))) if(!fdef->base->args) return GW_OK; - ++env->scope->depth; - const m_bool ret = scan1_args(env, fdef->base->args); - --env->scope->depth; - return ret; + RET_NSPC(scan1_args(env, fdef->base->args)) } ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) { diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 7e9bde94..b0a6c336 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -74,10 +74,7 @@ ANN m_bool scan2_fptr_def(const Env env NUSED, const Fptr_Def fptr) { if(!tmpl_base(fptr->base->tmpl)) { const Func_Def def = fptr->type->e->d.func->def; if(def->base->args) { - ++env->scope->depth; - const m_bool ret = scan2_args(def); - --env->scope->depth; - return ret; + RET_NSPC(scan2_args(def)) } } else SET_FLAG(fptr->type, func);