From: simonpj Date: Thu, 6 Jan 2005 10:04:30 +0000 (+0000) Subject: [project @ 2005-01-06 10:04:30 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~1292 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=82098fef0a9a0c9a073f782479c124798e9d1cef;p=ghc-hetmet.git [project @ 2005-01-06 10:04:30 by simonpj] Wibble to ambiguity reporting --- diff --git a/ghc/compiler/typecheck/TcSimplify.lhs b/ghc/compiler/typecheck/TcSimplify.lhs index c1d0673..97aca4d 100644 --- a/ghc/compiler/typecheck/TcSimplify.lhs +++ b/ghc/compiler/typecheck/TcSimplify.lhs @@ -1933,15 +1933,15 @@ tc_simplify_top is_interactive wanteds bad_guys = non_stds ++ concat std_bads (non_ips, bad_ips) = partition isClassDict bad_guys (ambigs, no_insts) = partition is_ambig non_ips - is_ambig d = not (isEmptyVarSet (tyVarsOfInst d)) + is_ambig d = not (tyVarsOfInst d `subVarSet` fixed_tvs) + fixed_tvs = oclose (fdPredsOfInsts irreds) emptyVarSet -- If the dict has free type variables, it's almost certainly ambiguous, - -- and that's the first thing to fix + -- and that's the first thing to fix. -- Otherwise, addNoInstanceErrs does the right thing - -- [ Previously, there was a different no_inst definition: - -- no_inst d = not (isTyVarDict d) || tyVarsOfInst d `subVarSet` fixed_tvs - -- fixed_tvs = oclose (fdPredsOfInsts tidy_dicts) emptyVarSet - -- But that seems over-elaborate to me; it only bites for class decls with - -- fundeps like this: class C a b | -> b where ...] + -- I say "almost certain" because we might have + -- class C a b | a -> B where ... + -- plus an Inst (C Int x). Then the 'x' isn't ambiguous; it's just that + -- there's no instance decl for (C Int ...). Hence the oclose. in -- Report definite errors