summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2019-03-11 10:02:31 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-12 09:13:28 -0400
commit50249a9f652ae3440e9462fdc9914edc924091f1 (patch)
tree013e20f8e82ecc722b85a28a42ae630e12d5803c /testsuite/tests/typecheck/should_fail
parent5165378d87602a8ce24776d220039fc05075d31f (diff)
downloadhaskell-50249a9f652ae3440e9462fdc9914edc924091f1.tar.gz
Use transSuperClasses in TcErrors
Code in TcErrors was recursively using immSuperClasses, which loops in the presence of UndecidableSuperClasses. Better to use transSuperClasses instead, which has a loop-breaker mechanism built in. Fixes issue #16414.
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
-rw-r--r--testsuite/tests/typecheck/should_fail/T16414.hs17
-rw-r--r--testsuite/tests/typecheck/should_fail/T16414.stderr13
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T16414.hs b/testsuite/tests/typecheck/should_fail/T16414.hs
new file mode 100644
index 0000000000..27807e82bf
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T16414.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE FlexibleContexts, FlexibleInstances, AllowAmbiguousTypes #-}
+{-# LANGUAGE UndecidableSuperClasses #-}
+module T16414 where
+
+data I = I
+
+class All2 x => All x
+class All x => All2 x
+
+class AllZip2 f
+instance AllZip2 f
+
+f1 :: (All x, AllZip2 I) => x -> ()
+f1 = f2
+
+f2 :: AllZip2 f => x -> ()
+f2 _ = ()
diff --git a/testsuite/tests/typecheck/should_fail/T16414.stderr b/testsuite/tests/typecheck/should_fail/T16414.stderr
new file mode 100644
index 0000000000..5cfbf7549a
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T16414.stderr
@@ -0,0 +1,13 @@
+
+T16414.hs:14:6: error:
+ • Overlapping instances for AllZip2 f0 arising from a use of ‘f2’
+ Matching givens (or their superclasses):
+ AllZip2 I
+ bound by the type signature for:
+ f1 :: forall x. (All x, AllZip2 I) => x -> ()
+ at T16414.hs:13:1-35
+ Matching instances:
+ instance AllZip2 f -- Defined at T16414.hs:11:10
+ (The choice depends on the instantiation of ‘f0’)
+ • In the expression: f2
+ In an equation for ‘f1’: f1 = f2
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index a5d1847bb0..b3c25eabe9 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -510,3 +510,4 @@ test('T16059e', [extra_files(['T16059b.hs'])], multimod_compile_fail,
['T16059e', '-v0'])
test('T16255', normal, compile_fail, [''])
test('T16204c', normal, compile_fail, [''])
+test('T16414', normal, compile_fail, [''])