[project @ 2001-05-03 08:52:52 by simonpj]
authorsimonpj <unknown>
Thu, 3 May 2001 08:52:52 +0000 (08:52 +0000)
committersimonpj <unknown>
Thu, 3 May 2001 08:52:52 +0000 (08:52 +0000)
Add a fundep fail test

ghc/tests/typecheck/should_fail/tcfail093.hs [new file with mode: 0644]
ghc/tests/typecheck/should_fail/tcfail093.stderr [new file with mode: 0644]

diff --git a/ghc/tests/typecheck/should_fail/tcfail093.hs b/ghc/tests/typecheck/should_fail/tcfail093.hs
new file mode 100644 (file)
index 0000000..74ee993
--- /dev/null
@@ -0,0 +1,31 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module ShouldFail where
+
+-- A stripped down functional-dependency 
+-- example that causes GHC 4.08.1 to crash with:
+-- "basicTypes/Var.lhs:194: Non-exhaustive patterns in function readMutTyVar"
+-- Reported by Thomas Hallgren Nov 00
+
+
+primDup :: Int -> IO Int
+primDup = undefined
+
+dup () = call primDup
+
+--     call :: Call c h => c -> h
+--
+--     call primDup :: {Call (Int -> IO Int) h} => h  with  
+--  Using the instance decl gives
+--     call primDup :: {Call (IO Int) h'} => Int -> h'
+--  The functional dependency means that h must be constant
+--  Hence program is rejected because it can't find an instance 
+--  for {Call (IO Int) h'}
+
+class Call    c h | c -> h where
+    call  :: c -> h
+
+instance Call c h => Call (Int->c) (Int->h) where 
+    call f = call . f
+
+
diff --git a/ghc/tests/typecheck/should_fail/tcfail093.stderr b/ghc/tests/typecheck/should_fail/tcfail093.stderr
new file mode 100644 (file)
index 0000000..a2a07fd
--- /dev/null
@@ -0,0 +1,5 @@
+
+tcfail093.hs:14:
+    No instance for `Call (IO Int) h'
+    arising from use of `call' at tcfail093.hs:14
+    In the definition of `dup': call primDup