From 9ced2b5962e84d84694cde112e1befe52f970d7b Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 25 Feb 2005 14:15:53 +0000 Subject: [PATCH] [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. --- ghc/compiler/typecheck/TcSimplify.lhs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) 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 -- 1.7.10.4