1 {-# OPTIONS -XFunctionalDependencies -XUndecidableInstances -XFlexibleInstances #-}

12 {- This used to be a bug in various versions of GHC <= 7.2.2

13 The source of the problem is the kicking out of inert Solved goals back to

14 the worklist, which violated our invariant that when two constraints of the

15 same class meet (workitem-inert) then the combination (Given-Wanted) is impossible.

16 Actually it turns our that it is possible. The order in which the constraints appear

17 below is important so we add two combinations to make sure that the testcase is

18 order-insensitive. -}

21 -- back in the worklist. Next time round the solved workitem

22 -- meets the wanted from stage (2) and boom, the assertion fails!

26 -- which immediately becomes [S] B Bool alpha

27 ]

32 ]

38 ]

43 ]

49 ]

55 ]

58 {- Now, in HEAD we no longer have cached GivenSolved goals in the inerts and hence

59 this situation can no longer appear. If a Given gets kicked out it is only because

60 it got rewritten by a given equality: Notice that since Givens now never contain

61 plain old unification variables (since they are not GivenSolveds!) they can never be

62 rewritten by a spontaneously solved either! So our invariant now holds. -}