From: fennecdjay Date: Wed, 11 Nov 2020 21:24:10 +0000 (+0100) Subject: :art: Improve checking :smile: X-Git-Tag: nightly~1164 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2bb3dc3d8f87589122829986d6506b948c4bcc33;p=gwion.git :art: Improve checking :smile: --- diff --git a/src/parse/check.c b/src/parse/check.c index c8d0b421..b5b903a0 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -758,6 +758,8 @@ ANN static m_bool predefined_call(const Env env, const Type t, const loc_t pos) ANN static Type check_exp_call(const Env env, Exp_Call* exp) { if(exp->tmpl) { CHECK_OO(check_exp(env, exp->func)) + if(exp->args) + CHECK_OO(check_exp(env, exp->args)) const Type t = actual_type(env->gwion, unflag_type(exp->func->info->type)); if(isa(t, env->gwion->type[et_function]) < 0) ERR_O(exp_self(exp)->pos, _("template call of non-function value.")) @@ -765,8 +767,6 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { ERR_O(exp_self(exp)->pos, _("template call of non-template function.")) if(t->info->func->def->base->tmpl->call) { if(env->func == t->info->func) { - if(exp->args) - CHECK_OO(check_exp(env, exp->args)) exp->m_func = env->func; return env->func->def->base->ret_type; } else diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 1e15b894..46a61bc4 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -28,16 +28,6 @@ ANN static inline Value template_get_ready(const Env env, const Value v, const m nspc_lookup_value1(v->from->owner, sym); } -ANN static m_bool check_call(const Env env, const Exp_Call* exp) { - const ae_exp_t et = exp->func->exp_type; - if(et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast) - ERR_B(exp->func->pos, _("invalid expression for function call.")) - CHECK_OB(check_exp(env, exp->func)) - if(exp->args) - CHECK_OB(check_exp(env, exp->args)) - return GW_OK; -} - ANN static inline m_bool tmpl_valid(const Env env, const Func_Def fdef) { return safe_fflag(fdef->base->func, fflag_valid) || check_traverse_fdef(env, fdef) > 0; @@ -118,7 +108,6 @@ ANN static Func func_match(const Env env, struct ResolverArgs* ra) { } ANN static Func _find_template_match(const Env env, const Value v, const Exp_Call* exp) { - CHECK_BO(check_call(env, exp)) const Type_List types = exp->tmpl->call; const Func former = env->func; DECL_OO(const m_str, tmpl_name, = tl2str(env, types)) @@ -138,7 +127,15 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal return m_func; } +ANN static inline m_bool check_call(const Env env, const Exp_Call* exp) { + const ae_exp_t et = exp->func->exp_type; + if(et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast) + ERR_B(exp->func->pos, _("invalid expression for function call.")) + return GW_OK; +} + ANN Func find_template_match(const Env env, const Value value, const Exp_Call* exp) { + CHECK_BO(check_call(env, exp)) const Func f = _find_template_match(env, value, exp); if(f) return f;