[commit: testsuite] master: Tests for T5684. They won't fail necessarily in 7.2.1 because (3131b9a)
dimitris at microsoft.com
dimitris at microsoft.com
Thu Dec 15 17:58:23 CET 2011
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/3131b9a9001726fa40f8142f98598d66725756ff
>---------------------------------------------------------------
commit 3131b9a9001726fa40f8142f98598d66725756ff
Author: Dimitrios Vytiniotis <dimitris at microsoft.com>
Date: Thu Dec 15 16:56:36 2011 +0000
Tests for T5684. They won't fail necessarily in 7.2.1 because
there was yet another bug (related to lazyness) but if the
T5684 bug appears again in HEAD then it will be revealed by
this test (because I also fixed the lazyness bug as well).
>---------------------------------------------------------------
tests/typecheck/should_fail/T5684.hs | 62 ++++++++++++++++++++++++++++++
tests/typecheck/should_fail/T5684.stderr | 20 ++++++++++
tests/typecheck/should_fail/all.T | 1 +
3 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/tests/typecheck/should_fail/T5684.hs b/tests/typecheck/should_fail/T5684.hs
new file mode 100755
index 0000000..a8c7259
--- /dev/null
+++ b/tests/typecheck/should_fail/T5684.hs
@@ -0,0 +1,62 @@
+{-# OPTIONS -XFunctionalDependencies -XUndecidableInstances -XFlexibleInstances #-}
+
+module T5684 where
+
+class B a b | a -> b where
+ op :: a -> b -> ()
+
+class A a
+
+instance A b => B Bool b
+
+{- This used to be a bug in various versions of GHC <= 7.2.2
+ The source of the problem is the kicking out of inert Solved goals back to
+ the worklist, which violated our invariant that when two constraints of the
+ same class meet (workitem-inert) then the combination (Given-Wanted) is impossible.
+ Actually it turns our that it is possible. The order in which the constraints appear
+ below is important so we add two combinations to make sure that the testcase is
+ order-insensitive. -}
+
+flop1 = [ op False False -- (3) Creates a functional dependency which kicks the solved out
+ -- back in the worklist. Next time round the solved workitem
+ -- meets the wanted from stage (2) and boom, the assertion fails!
+
+ , op 'c' undefined -- (2) Creates a ([W] B Char beta) permanently in inerts
+ , op True undefined -- (1) Creates ([W] B Bool alpha)
+ -- which immediately becomes [S] B Bool alpha
+ ]
+
+flop2 = [ op False False
+ , op True undefined
+ , op 'c' undefined
+ ]
+
+
+flop3 = [ op 'c' undefined
+ , op True undefined
+ , op False False
+ ]
+
+flop4 = [ op 'c' undefined
+ , op False False
+ , op True undefined
+ ]
+
+
+flop5 = [ op True undefined
+ , op 'c' undefined
+ , op False False
+ ]
+
+
+flop6 = [ op True undefined
+ , op False False
+ , op 'c' undefined
+ ]
+
+
+{- Now, in HEAD we no longer have cached GivenSolved goals in the inerts and hence
+ this situation can no longer appear. If a Given gets kicked out it is only because
+ it got rewritten by a given equality: Notice that since Givens now never contain
+ plain old unification variables (since they are not GivenSolveds!) they can never be
+ rewritten by a spontaneously solved either! So our invariant now holds. -}
diff --git a/tests/typecheck/should_fail/T5684.stderr b/tests/typecheck/should_fail/T5684.stderr
new file mode 100644
index 0000000..0d02978
--- /dev/null
+++ b/tests/typecheck/should_fail/T5684.stderr
@@ -0,0 +1,20 @@
+
+T5684.hs:24:12:
+ No instance for (B Char b5)
+ arising from a use of `op'
+ Possible fix: add an instance declaration for (B Char b5)
+ In the expression: op 'c' undefined
+ In the expression:
+ [op False False, op 'c' undefined, op True undefined]
+ In an equation for `flop1':
+ flop1 = [op False False, op 'c' undefined, op True undefined]
+
+T5684.hs:53:12:
+ No instance for (A Bool)
+ arising from a use of `op'
+ Possible fix: add an instance declaration for (A Bool)
+ In the expression: op False False
+ In the expression:
+ [op True undefined, op False False, op 'c' undefined]
+ In an equation for `flop6':
+ flop6 = [op True undefined, op False False, op 'c' undefined]
diff --git a/tests/typecheck/should_fail/all.T b/tests/typecheck/should_fail/all.T
index 3bebfab..3585f4a 100644
--- a/tests/typecheck/should_fail/all.T
+++ b/tests/typecheck/should_fail/all.T
@@ -269,3 +269,4 @@ test('T5570', normal, compile_fail, [''])
test('T5573a', normal, compile_fail, [''])
test('T5573b', normal, compile_fail, [''])
test('T5689', normal, compile_fail, [''])
+test('T5684', normal, compile_fail, [''])
\ No newline at end of file
More information about the Cvs-ghc
mailing list