[project @ 2005-02-25 14:15:53 by simonpj]
authorsimonpj <unknown>
Fri, 25 Feb 2005 14:15:53 +0000 (14:15 +0000)
committersimonpj <unknown>
Fri, 25 Feb 2005 14:15:53 +0000 (14:15 +0000)
-----------------------------------------
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

index 8b1fed0..e7cfee9 100644 (file)
@@ -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