Commit 029367e5 authored by thomie's avatar thomie Committed by Ben Gamari
Browse files

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:
parent 7f37274d
......@@ -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, [''])
{-# 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
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’
......@@ -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
......@@ -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
Markdown is supported
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