From 65128ed7812c6e8085c0f0258f23f6afad3a6b50 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Thu, 3 Oct 2013 09:25:25 +0100 Subject: Test Trac #8392 --- testsuite/tests/typecheck/should_compile/T8392.hs | 17 +++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + testsuite/tests/typecheck/should_fail/T8392a.hs | 7 +++++++ testsuite/tests/typecheck/should_fail/T8392a.stderr | 7 +++++++ testsuite/tests/typecheck/should_fail/all.T | 2 ++ 5 files changed, 34 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/T8392.hs create mode 100644 testsuite/tests/typecheck/should_fail/T8392a.hs create mode 100644 testsuite/tests/typecheck/should_fail/T8392a.stderr diff --git a/testsuite/tests/typecheck/should_compile/T8392.hs b/testsuite/tests/typecheck/should_compile/T8392.hs new file mode 100644 index 0000000000..d86d29b8bc --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T8392.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies, UndecidableInstances, AllowAmbiguousTypes #-} + +module T8392 where + +class Fun f a b where + fun :: f -> a -> b + +instance (b ~ Int, a ~ Int) => Fun F a b + where fun _ = (+1) + +data F = F + +data Compose a b = Compose a b + +-- ghc-7.6 version +instance (Fun f b c, Fun g a b) => Fun (Compose f g) a c where + fun (Compose f g) a = fun f (fun g a :: b) \ No newline at end of file diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index eb0e934220..0ccd90a35e 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -410,3 +410,4 @@ test('T7891', normal, compile, ['']) test('T7903', normal, compile, ['']) test('TcTypeNatSimple', normal, compile, ['']) test('TcCoercibleCompile', when(compiler_lt('ghc', '7.7'), skip), compile, ['']) +test('T8392', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_fail/T8392a.hs b/testsuite/tests/typecheck/should_fail/T8392a.hs new file mode 100644 index 0000000000..6f47b4e331 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T8392a.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE GADTs, AllowAmbiguousTypes #-} +module T8392a where + +-- Should complain even with AllowAmbiguousTypes + +foo :: (Int ~ Bool) => a -> a +foo x = x diff --git a/testsuite/tests/typecheck/should_fail/T8392a.stderr b/testsuite/tests/typecheck/should_fail/T8392a.stderr new file mode 100644 index 0000000000..6e102227cf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T8392a.stderr @@ -0,0 +1,7 @@ + +T8392a.hs:6:8: + Couldn't match type ‛Int’ with ‛Bool’ + Inaccessible code in + the type signature for foo :: Int ~ Bool => a -> a + In the ambiguity check for: forall a. Int ~ Bool => a -> a + In the type signature for ‛foo’: foo :: Int ~ Bool => a -> a diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index cac7d92a13..bf11f6c94b 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -320,3 +320,5 @@ test('TcCoercibleFail', when(compiler_lt('ghc', '7.7'), skip), compile_fail, ['' test('TcCoercibleFailSafe', when(compiler_lt('ghc', '7.7'), skip), compile_fail, ['']) test('TcCoercibleFail2', when(compiler_lt('ghc', '7.7'), skip), compile_fail, ['']) test('T8306', normal, compile_fail, ['']) +test('T8392a', normal, compile_fail, ['']) + -- cgit v1.2.1