X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Ftypecheck%2FTcSimplify.lhs;h=02ed4d5724ae0c2f35bf5de130c7174af3c5f63a;hb=e26b57633244b75c41f684e48f2681d25978f43f;hp=7a971abcc699ce2a4566ae8fd0366ea65dcbecfd;hpb=d255dfff87648bcd4dd1d87faa8d835d358c70a2;p=ghc-hetmet.git diff --git a/ghc/compiler/typecheck/TcSimplify.lhs b/ghc/compiler/typecheck/TcSimplify.lhs index 7a971ab..02ed4d5 100644 --- a/ghc/compiler/typecheck/TcSimplify.lhs +++ b/ghc/compiler/typecheck/TcSimplify.lhs @@ -2051,8 +2051,15 @@ addNoInstanceErrs mb_what givens dicts | not (isClassDict dict) = (overlap_doc, dict : no_inst_dicts) | otherwise = case lookupInstEnv dflags inst_envs clas tys of - ([], _) -> (overlap_doc, dict : no_inst_dicts) -- No matches - inst_res -> (mk_overlap_msg dict inst_res $$ overlap_doc, no_inst_dicts) + res@(ms, _) + | length ms > 1 -> (mk_overlap_msg dict res $$ overlap_doc, no_inst_dicts) + | otherwise -> (overlap_doc, dict : no_inst_dicts) -- No match + -- NB: there can be exactly one match, in the case where we have + -- instance C a where ... + -- (In this case, lookupInst doesn't bother to look up, + -- unless -fallow-undecidable-instances is set.) + -- So we report this as "no instance" rather than "overlap"; the fix is + -- to specify -fallow-undecidable-instances, but we leave that to the programmer! where (clas,tys) = getDictClassTys dict in