From: simonpj Date: Fri, 25 Feb 2005 14:15:53 +0000 (+0000) Subject: [project @ 2005-02-25 14:15:53 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~1017 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=9ced2b5962e84d84694cde112e1befe52f970d7b [project @ 2005-02-25 14:15:53 by simonpj] ----------------------------------------- Improve ambiguity reporting in TcSimplify ----------------------------------------- Merge to STABLE The test for ambiguity in tcSimplifyTop caused us to say thing like No instance for (Show c) which is a bit confusing -- and in fact exposed a separate buglet in the fix-reporting code. This commit deals with the origial problem. tcfail133 tests it. --- diff --git a/ghc/compiler/typecheck/TcSimplify.lhs b/ghc/compiler/typecheck/TcSimplify.lhs index 8b1fed0..e7cfee9 100644 --- a/ghc/compiler/typecheck/TcSimplify.lhs +++ b/ghc/compiler/typecheck/TcSimplify.lhs @@ -1967,16 +1967,10 @@ tc_simplify_top is_interactive wanteds -- Collect together all the bad guys 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 (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. - -- Otherwise, addNoInstanceErrs does the right thing - -- 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. + (ambigs, no_insts) = partition isTyVarDict non_ips + -- If the dict has no type constructors involved, it must be ambiguous, + -- except I suppose that another error with fundeps maybe should have + -- constrained those type variables in -- Report definite errors