summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-07-20 15:40:59 +0200
committerBen Gamari <ben@smart-cactus.org>2015-07-20 16:10:14 +0200
commit029367e5894d4ac3ea3845f39f2cc1b5a6a9fac1 (patch)
treebe87a08f43a67be74dcf90146ab26a0b7c9d5644
parent7f37274d9f6de8c53cbf7fce3c39ad19cebdbbb5 (diff)
downloadhaskell-029367e5894d4ac3ea3845f39f2cc1b5a6a9fac1.tar.gz
Testsuite: add regression test for missing class constraint
The following program is accepted by ghc-7.0 to ghc-7.10, but rejected by ghc-6.12.3 and HEAD (and rightfully so): class Class1 a class Class1 a => Class2 a class Class2 a => Class3 a instance Class3 a => Class2 a The last line is missing a `Class1 a` constraint. Add a regression test for this (typechecker/should_fail/tcfail223). Add similar missing class constraints to T7126 and T5751. I verified that the these changes don't interfer with the intention of the tests (they still result in a loop with ghc-7.4.1). Reviewers: austin, simonpj, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D1078
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail223.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail223.stderr9
-rw-r--r--testsuite/tests/typecheck/should_run/T5751.hs2
-rw-r--r--testsuite/tests/typecheck/should_run/T7126.hs2
5 files changed, 22 insertions, 2 deletions
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index d1bf03b37e..fbbeddbbe0 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -246,6 +246,7 @@ test('tcfail219', normal, multimod_compile_fail, ['tcfail219.hsig', '-sig-of "Sh
test('tcfail220', normal, multimod_compile_fail, ['tcfail220.hsig', '-sig-of "ShouldFail is base:Prelude"'])
test('tcfail221', normal, multimod_compile_fail, ['tcfail221.hsig', '-sig-of "ShouldFail is base:Prelude"'])
test('tcfail222', normal, multimod_compile_fail, ['tcfail222.hsig', '-sig-of "ShouldFail is base:Data.STRef"'])
+test('tcfail223', normal, compile_fail, [''])
test('SilentParametersOverlapping', normal, compile, [''])
test('FailDueToGivenOverlapping', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/tcfail223.hs b/testsuite/tests/typecheck/should_fail/tcfail223.hs
new file mode 100644
index 0000000000..e5e0d5c8f8
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/tcfail223.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
+module ShouldFail where
+
+class Class1 a
+class Class1 a => Class2 a
+class Class2 a => Class3 a
+
+-- This was wrongfully accepted by ghc-7.0 to ghc-7.10.
+-- It is missing a `Class1 a` constraint.
+instance Class3 a => Class2 a
diff --git a/testsuite/tests/typecheck/should_fail/tcfail223.stderr b/testsuite/tests/typecheck/should_fail/tcfail223.stderr
new file mode 100644
index 0000000000..e4a4fcda54
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/tcfail223.stderr
@@ -0,0 +1,9 @@
+
+tcfail223.hs:10:10: error:
+ Could not deduce (Class1 a)
+ arising from the superclasses of an instance declaration
+ from the context: Class3 a
+ bound by the instance declaration at tcfail223.hs:10:10-29
+ Possible fix:
+ add (Class1 a) to the context of the instance declaration
+ In the instance declaration for ‘Class2 a’
diff --git a/testsuite/tests/typecheck/should_run/T5751.hs b/testsuite/tests/typecheck/should_run/T5751.hs
index 423a40736d..7c7d8ab0b9 100644
--- a/testsuite/tests/typecheck/should_run/T5751.hs
+++ b/testsuite/tests/typecheck/should_run/T5751.hs
@@ -25,7 +25,7 @@ main =
class (Widgets x) => MonadRender x
class (XMLGenerator m) => Widgets m
-- instance Widgets (IdentityT IO) -- if you uncomment this, it will work
-instance MonadRender m => Widgets m
+instance (XMLGenerator m, MonadRender m) => Widgets m
instance MonadRender (IdentityT IO)
web :: ( MonadIO m
diff --git a/testsuite/tests/typecheck/should_run/T7126.hs b/testsuite/tests/typecheck/should_run/T7126.hs
index ce9792de37..184d5df1f0 100644
--- a/testsuite/tests/typecheck/should_run/T7126.hs
+++ b/testsuite/tests/typecheck/should_run/T7126.hs
@@ -24,7 +24,7 @@ class Class2 a => Class3 a where
instance Class1 Int where
func1 = id
-instance Class3 a => Class2 a where
+instance (Class1 a, Class3 a) => Class2 a where
func2 = func3
instance Class3 Int where