Commit abfcdc0a authored by dimitris's avatar dimitris
Browse files

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).
parent de8a1bf1
{-# 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. -}
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]
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment