From 1bc571823dd89b98d9ef31b42aab8337a0e93051 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 12 May 2022 22:09:09 +0200 Subject: [PATCH] :bug fix partial ambiguity --- src/parse/partial.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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; -- 2.43.0