From: Jérémie Astor Date: Thu, 12 May 2022 20:09:09 +0000 (+0200) Subject: :bug fix partial ambiguity X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=1bc571823dd89b98d9ef31b42aab8337a0e93051;p=gwion.git :bug fix partial ambiguity --- diff --git a/src/parse/partial.c b/src/parse/partial.c index 8a32be05..b78fa535 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -136,15 +136,19 @@ ANN void ambiguity(const Env env, Func f, const Exp args, const loc_t loc) { ANN static Func partial_match(const Env env, const Func up, const Exp args, const loc_t loc) { const Func f = find_match_actual(env, up, args); if(f) { + const Type t = f->value_ref->from->owner_class; if(f->next) { const Func next = partial_match(env, f->next, args, loc); if(next) { - gwerr_basic(_("can't resolve ambiguity"), _("in this partial application"), _("use typed holes: _ $ type"), env->name, loc, 0); - gw_err(_("\nthose functions could match:\n")); - print_signature(f); - ambiguity(env, next, args, loc); - env->context->error = true; - return NULL; + const Type tnext = next->value_ref->from->owner_class; + if(!t || !tnext || isa(t, tnext) < 0) { + gwerr_basic(_("can't resolve ambiguity"), _("in this partial application"), _("use typed holes: _ $ type"), env->name, loc, 0); + gw_err(_("\nthose functions could match:\n")); + print_signature(f); + ambiguity(env, next, args, loc); + env->context->error = true; + return NULL; + } } } return f;