[commit: ghc] master: Testsuite: add regression test for missing class constraint (029367e)
git at git.haskell.org
git at git.haskell.org
Mon Jul 20 15:05:59 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/029367e5894d4ac3ea3845f39f2cc1b5a6a9fac1/ghc
>---------------------------------------------------------------
commit 029367e5894d4ac3ea3845f39f2cc1b5a6a9fac1
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Mon Jul 20 15:40:59 2015 +0200
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
>---------------------------------------------------------------
029367e5894d4ac3ea3845f39f2cc1b5a6a9fac1
testsuite/tests/typecheck/should_fail/all.T | 1 +
testsuite/tests/typecheck/should_fail/tcfail223.hs | 10 ++++++++++
testsuite/tests/typecheck/should_fail/tcfail223.stderr | 9 +++++++++
testsuite/tests/typecheck/should_run/T5751.hs | 2 +-
testsuite/tests/typecheck/should_run/T7126.hs | 2 +-
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 d1bf03b..fbbeddb 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 0000000..e5e0d5c
--- /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 0000000..e4a4fcd
--- /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 423a407..7c7d8ab 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 ce9792d..184d5df 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
More information about the ghc-commits
mailing list