Commit 8a07a522 authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Ben Gamari

Fix over-eager error suppression in TcErrors

See Note [Given insolubles] in TcRnTypes

Fixes Trac #14325.

(cherry picked from commit c81f66cc)
parent 404bf05e
......@@ -2251,7 +2251,7 @@ trulyInsoluble :: Ct -> Bool
-- Yuk!
trulyInsoluble insol
| isHoleCt insol = isOutOfScopeCt insol
| otherwise = True
| otherwise = not (isGivenCt insol) -- See Note [Given insolubles]
instance Outputable WantedConstraints where
ppr (WC {wc_simple = s, wc_impl = i, wc_insol = n})
......@@ -2266,7 +2266,27 @@ ppr_bag doc bag
| otherwise = hang (doc <+> equals)
2 (foldrBag (($$) . ppr) empty bag)
{-
{- Note [Given insolubles]
~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (Trac #14325, comment:)
class (a~b) => C a b
foo :: C a b => a -> b
foo x = x
hm3 :: C (f b) b => b -> f b
hm3 x = foo x
From the [G] C (f b) b we get the insoluble [G] f b ~# b. Then we we also
get an unsolved [W] C b (f b). If trulyInsouble is true of this, we'll
set cec_suppress to True, and suppress reports of the [W] C b (f b). But we
may not report the insoluble [G] f b ~# b either (see Note [Given errors]
in TcErrors), so we may fail to report anything at all! Yikes.
Bottom line: we must be certain to report anything trulyInsoluble. Easiest
way to guaranteed this is to make truly Insoluble false of Givens.
************************************************************************
* *
Implication constraints
......
{-# LANGUAGE GADTs, MultiParamTypeClasses #-}
module T14325 where
class (a~b) => C a b
foo :: C a b => a -> b
foo x = x
hm3 :: C (f b) b => b -> f b
hm3 x = foo x
T14325.hs:11:9: error:
• Could not deduce (C b (f b)) arising from a use of ‘foo’
from the context: C (f b) b
bound by the type signature for:
hm3 :: forall (f :: * -> *) b. C (f b) b => b -> f b
at T14325.hs:10:1-28
• In the expression: foo x
In an equation for ‘hm3’: hm3 x = foo x
......@@ -437,4 +437,4 @@ test('T13677', normal, compile_fail, [''])
test('T14000', normal, compile_fail, [''])
test('T11672', normal, compile_fail, [''])
test('T13929', normal, compile_fail, [''])
test('T14325', normal, compile_fail, [''])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment