Tmpl *tm = fdef->base->tmpl;
if (tm->call) return check_predefined(env, exp, value, tm, fdef);
DECL_OO(const Type_List, tl, = check_template_args(env, exp, tm, fdef));
- ;
Tmpl tmpl = {.call = tl};
((Exp_Call *)exp)->tmpl = &tmpl;
DECL_OO(const Func, func, = get_template_func(env, exp, value));
}
ANN static Type check_exp_call(const Env env, Exp_Call *exp) {
- if (curried(env, exp->args)) return env->gwion->type[et_curry];
+ if (env->scope->allow_curry && curried(env, exp->args)) return env->gwion->type[et_curry];
if (exp->tmpl) {
DECL_BO(const m_bool, ret, = func_check(env, exp));
if (!ret) return exp_self(exp)->type;
//! check if type matches for template operator
ANN bool _tmpl_match(const Env env, const Type t, Type_Decl *const td,
- Specialized_List *sl) {
- if (!td->next && td->xid == (*sl)->xid) {
- *sl = (*sl)->next;
+ Specialized_List *slp) {
+ const Specialized_List sl = *slp;
+ if (sl && !td->next && !td->types && td->xid == sl->xid) {
+ *slp = sl->next;
return true;
}
const Type base = known_type(env, td);
- return isa(t, base) > 0;
+ return base ? isa(t, base) > 0 : false;
}
//! check Func_Base matches for template operator
+// usage of `is_class` is supicious rn
ANN bool tmpl_match(const Env env, const struct Op_Import *opi,
Func_Base *const base) {
Specialized_List sl = base->tmpl->list;
const Arg_List arg = base->args;
if (opi->lhs) {
- if (fbflag(base, fbflag_unary) ||
- !_tmpl_match(env, opi->lhs, arg->td, &sl) ||
- (opi->rhs && fbflag(base, fbflag_postfix)) ||
- !_tmpl_match(env, opi->rhs, arg->next->td, &sl))
- return false;
+ if (!_tmpl_match(env, opi->lhs, arg->td, &sl))
+ return false;
+ if (fbflag(base, fbflag_postfix))
+ return !!opi->rhs;
+ if (!fbflag(base, fbflag_unary)) {
+ if(!opi->rhs)return false;
+ if (!_tmpl_match(env, opi->rhs, arg->next->td, &sl))
+ return false;
+ } else if(opi->rhs) return false;
} else {
if (!fbflag(base, fbflag_unary) ||
!_tmpl_match(env, opi->rhs, arg->td, &sl))
const Vector v = &nspc->info->op_tmpl;
for (m_uint i = vector_size(v) + 1; --i;) {
const Func_Def fdef = (Func_Def)vector_at(v, i - 1);
+ if(opi->op != fdef->base->xid) continue;
if (!tmpl_match(env, opi, fdef->base)) continue;
return op_def(env, opi, fdef);
}