summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/tcfail080.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/tcfail080.hs')
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail080.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/tcfail080.hs b/testsuite/tests/typecheck/should_fail/tcfail080.hs
new file mode 100644
index 0000000000..b2a62cea54
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/tcfail080.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE MultiParamTypeClasses #-}
+
+-- !!! Multi-param type classes test: ambiguity bug
+
+-- GHC actually accepts this program because
+-- q :: Collection c a => a -> Bool
+-- and there is no a priori reason to suppose that
+-- q would be ambiguous in every context. For example,
+-- it could be fine if we had
+-- instance c Int where ...
+-- Of course, it'd be hard to fill in the "..." in this particular
+-- case, but that relies on observations about the form of the types
+-- of the class methods, surely beyond what a compiler should do.
+-- That's why GHC accepts it
+
+module ShouldFail where
+
+class Collection c a where
+ empty :: c a
+ add :: a -> c a -> c a
+ isempty :: c a -> Bool
+
+singleton x = add x empty
+
+q x = isempty (singleton x)
+
+