Commit 81ccf8a2 authored by simonpj's avatar simonpj
Browse files

[project @ 2004-12-15 15:14:37 by simonpj]

Add several more tests
parent 09b8064e
{-# OPTIONS -fallow-undecidable-instances #-}
-- Compiles fine.
-- Instance selection works fine.
-- try: :t foo (T1b T1a)
module ShouldCompile where
-- Notice: T1 is a recursive type.
-- Notice: the classes are recursive, too.
-- Why does this work when almost the same thing doesn't?
-- Say: adding an Int component to T1a makes things loop.
-- See LoopOfTheDay2.hs and LoopOfTheDay3.hs.
data T1 = T1a | T1b T1
class C0 x where foo :: x -> (); foo = undefined
class C1 x y
class C1 x y => C2 x y
instance C0 T1 => C1 () T1 -- (I1)
instance (C1 x T1) => C2 x T1 -- (I2)
instance C2 () T1 => C0 T1 -- (I3)
baz = foo (T1b T1a)
{- Need C0 T1
-->(I3) C2 () T1
-->(I2) C1 () T1
-->(I1) C0 T1 -- STOP because we've seen this before
-}
{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-undecidable-instances #-}
-- Compilation loops in GHC 6.2!
-- While LoopOfTheDay1.hs did compile and work,
-- this one loops during compilation, even though
-- there is only an innocent difference regarding T1,
-- i.e., an additional, non-recursive constructor component.
module ShouldCompile where
data T1 = T1a Int | T1b T1
class C0 x where foo :: x -> (); foo = undefined
-- foo :: C0 x => x -> ()
class C1 x y
class C1 x y => C2 x y
instance C0 Int => C1 () Int -- I1
instance C0 T1 => C1 () T1 -- I2
instance (C1 x T1, C1 x Int) => C2 x T1 -- I3
instance C1 x Int => C2 x Int -- I4
instance C2 () T1 => C0 T1 -- I5
instance C2 () Int => C0 Int -- I6
baz = foo (T1b (T1a 3))
{- Need
C0 T1
-->(I5) C2 () T1
-->(I3) C1 () T1, C1 () Int
-->(I1,I2) C0 T1, C0 Int
-->(recusive) C0 Int
-->(I6) C2 () Int
-->(I4) C1 () Int
-->(recursive) {}
-}
{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-undecidable-instances #-}
{-# OPTIONS -fallow-overlapping-instances #-}
-- Instances compile fine but instance selection loops in GHC 6.2.
-- try: :t foo (T1a 1)
-- This is essentially the same as LoopOfTheDay2.hs
-- but with the innocent (?) use of overlapping instances.
module ShouldCompile where
data T1 = T1a Int | T1b T1
class C0 x where foo :: x -> (); foo = undefined
class C1 x y
class C1 x y => C2 x y
instance C0 a => C1 () a
instance (C1 x T1, C1 x Int) => C2 x T1
instance C1 x Int => C2 x Int
instance C2 () a => C0 a
baz = foo (T1b (T1a 3))
......@@ -194,3 +194,9 @@ test('tc181', normal, compile, [''])
test('tc182', normal, compile, [''])
test('tc183', normal, compile, [''])
test('tc184', normal, compile, [''])
test('tc185', normal, compile, [''])
test('tc186', normal, compile, [''])
test('LoopOfTheDay1', normal, compile, [''])
test('LoopOfTheDay2', normal, compile, [''])
test('LoopOfTheDay3', normal, compile, [''])
{-# OPTIONS -fglasgow-exts #-}
-- Killed GHC 6.3 HEAD
module Bug where
import GHC.Base
foo v = let I# x# = 7 * 7 in "Forty-Two"
\ No newline at end of file
-- Killed 6.2.2
-- The trouble was that 1 was instantiated to a type (t::?)
-- and the constraint (Foo (t::? -> s::*)) didn't match Foo (a::* -> b::*).
-- Solution is to zap the expected type in TcEpxr.tc_expr(HsOverLit).
module ShoudlCompile where
class Foo a where
foo :: a
instance Foo (a -> b) where
foo = error "urk"
test :: ()
test = foo 1
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