diff options
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/tc176.hs')
-rw-r--r-- | testsuite/tests/typecheck/should_compile/tc176.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/tc176.hs b/testsuite/tests/typecheck/should_compile/tc176.hs new file mode 100644 index 0000000000..d05ccdbe29 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/tc176.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE FlexibleInstances, OverlappingInstances #-} + +{- With "hugs -98 +o test.hs" gives me: + ERROR "test.hs":8 - Cannot justify constraints in instance member binding + *** Expression : fromStr + *** Type : FromStr [a] => String -> [a] + *** Given context : FromStr [a] + *** Constraints : FromStr [a] + + Adding the constraint "FromStr a" to the declaration of fromStr fixes + the problem, but that seems like it should be redundant. Removing the + second instance (lines 10-11) also fixes the problem, interestingly enough. + + /Bjorn Bringert -} + +-- August 08: on reflection I think a complaint about overlapping +-- instances for line 8 is absolutely right, so I've changed this to +-- expected-failure + +-- Sept 08: on further reflection (!) I'm changing it back +-- See Note [Subtle interaction of recursion and overlap] +-- in TcInstDcls + +module ShouldCompile where + +class FromStr a where + fromStr :: String -> a + +typeError :: FromStr a => a -> a +typeError t = error "type error" + +instance FromStr [a] where + fromStr _ = typeError undefined -- line 8 + +instance FromStr [(String,a)] where -- line 10 + fromStr _ = typeError undefined -- line 11 |