Commit 5b2940f4 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Test Trac #5051

parent 6826e084
{-# LANGUAGE FlexibleInstances, OverlappingInstances #-}
-- A very delicate interaction of overlapping instances
module T5051 where
data T = T deriving( Eq, Ord )
instance Eq [T]
foo :: Ord a => [a] -> Bool
foo x = x >= x
-- Bizarrely, the defn of 'foo' failed in GHC 7.0.3 with
-- T5051.hs:14:10:
-- Overlapping instances for Eq [a]
-- arising from a use of `>'
-- Matching instances:
-- instance Eq a => Eq [a] -- Defined in GHC.Classes
-- instance [overlap ok] Eq [T] -- Defined at T5051.hs:9:10-15
-- (The choice depends on the instantiation of `a'
-- To pick the first instance above, use -XIncoherentInstances
-- when compiling the other instance declarations)
-- In the expression: x > x
-- Reason: the dfun for Ord [a] (in the Prelude) had a "silent"
-- superclass parameter, thus
-- $dfOrdList :: forall a. (Eq [a], Ord a) => Ord [a]
-- Using the dfun means we need Eq [a], and that gives rise to the
-- overlap error.
-- This is terribly confusing: the use of (>=) means we need Ord [a],
-- and if we have Ord a (which we do) we should be done.
-- A very good reason for not having silent parameters!
......@@ -343,4 +343,5 @@ test('tc249', normal, compile, [''])
test('GivenOverlapping', normal, compile, [''])
test('SilentParametersOverlapping', normal, compile, [''])
test('GivenTypeSynonym', normal, compile, [''])
\ No newline at end of file
test('GivenTypeSynonym', normal, compile, [''])
test('T5051', normal, compile, [''])
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