From 5a3d608fc309666876d7decaff9824ff0ea22045 Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 3 May 2001 08:52:52 +0000 Subject: [PATCH] [project @ 2001-05-03 08:52:52 by simonpj] Add a fundep fail test --- ghc/tests/typecheck/should_fail/tcfail093.hs | 31 ++++++++++++++++++++++ ghc/tests/typecheck/should_fail/tcfail093.stderr | 5 ++++ 2 files changed, 36 insertions(+) create mode 100644 ghc/tests/typecheck/should_fail/tcfail093.hs create mode 100644 ghc/tests/typecheck/should_fail/tcfail093.stderr diff --git a/ghc/tests/typecheck/should_fail/tcfail093.hs b/ghc/tests/typecheck/should_fail/tcfail093.hs new file mode 100644 index 0000000..74ee993 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail093.hs @@ -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 index 0000000..a2a07fd --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail093.stderr @@ -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 -- 1.7.10.4