diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/deriving/should_fail | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/deriving/should_fail')
70 files changed, 757 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_fail/Makefile b/testsuite/tests/deriving/should_fail/Makefile new file mode 100644 index 0000000000..0f0995d29d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/Makefile @@ -0,0 +1,8 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +drvfail016: + $(RM) -f drvfail016.hi-boot drvfail016.o-boot + '$(TEST_HC)' $(TEST_HC_OPTS) -XGeneralizedNewtypeDeriving -c drvfail016.hs-boot; echo $$? + diff --git a/testsuite/tests/deriving/should_fail/T2394.hs b/testsuite/tests/deriving/should_fail/T2394.hs new file mode 100644 index 0000000000..6e62bc364e --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2394.hs @@ -0,0 +1,9 @@ +{-# OPTIONS_GHC -XDeriveDataTypeable -XStandaloneDeriving #-} + +-- Test Trac #2394 + +module Foo where + +import Data.Data(Data) + +deriving instance (Data a,Data b) => Data (a->b) diff --git a/testsuite/tests/deriving/should_fail/T2394.stderr b/testsuite/tests/deriving/should_fail/T2394.stderr new file mode 100644 index 0000000000..9972186ed5 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2394.stderr @@ -0,0 +1,6 @@ +
+T2394.hs:9:1:
+ Can't make a derived instance of `Data (a -> b)':
+ The last argument of the instance must be a data or newtype application
+ In the stand-alone deriving instance for
+ `(Data a, Data b) => Data (a -> b)'
diff --git a/testsuite/tests/deriving/should_fail/T2604.hs b/testsuite/tests/deriving/should_fail/T2604.hs new file mode 100644 index 0000000000..0f830d992b --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2604.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + +module Test where + +import Data.Typeable + +data DList a = DList [a] deriving(Typeable) + +newtype NList a = NList [a] deriving(Typeable) diff --git a/testsuite/tests/deriving/should_fail/T2604.stderr b/testsuite/tests/deriving/should_fail/T2604.stderr new file mode 100644 index 0000000000..fa09654c5b --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2604.stderr @@ -0,0 +1,10 @@ +
+T2604.hs:7:35:
+ Can't make a derived instance of `Typeable (DList a)':
+ You need -XDeriveDataTypeable to derive an instance for this class
+ In the data type declaration for `DList'
+
+T2604.hs:9:38:
+ Can't make a derived instance of `Typeable (NList a)':
+ You need -XDeriveDataTypeable to derive an instance for this class
+ In the newtype declaration for `NList'
diff --git a/testsuite/tests/deriving/should_fail/T2604.stderr-7.0 b/testsuite/tests/deriving/should_fail/T2604.stderr-7.0 new file mode 100644 index 0000000000..aa996e0f87 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2604.stderr-7.0 @@ -0,0 +1,11 @@ +
+T2604.hs:7:35:
+ Can't make a derived instance of `Typeable (DList a)':
+ You need -XDeriveDataTypeable to derive an instance for this class
+ In the data type declaration for `DList'
+
+T2604.hs:9:38:
+ Can't make a derived instance of `Typeable (NList a)'
+ (even with cunning newtype deriving): + You need -XDeriveDataTypeable to derive an instance for this class
+ In the newtype declaration for `NList'
diff --git a/testsuite/tests/deriving/should_fail/T2701.hs b/testsuite/tests/deriving/should_fail/T2701.hs new file mode 100644 index 0000000000..37bffc827d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2701.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE MagicHash, DeriveDataTypeable #-}
+module T2700 where
+
+import GHC.Prim
+
+import Data.Data
+import Data.Typeable
+
+data Foo = MkFoo Int#
+ deriving (Typeable, Data)
diff --git a/testsuite/tests/deriving/should_fail/T2701.stderr b/testsuite/tests/deriving/should_fail/T2701.stderr new file mode 100644 index 0000000000..a9181accc1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2701.stderr @@ -0,0 +1,5 @@ + +T2701.hs:10:32: + Can't make a derived instance of `Data Foo': + Constructor `MkFoo' must have only arguments of lifted type + In the data type declaration for `Foo' diff --git a/testsuite/tests/deriving/should_fail/T2721.hs b/testsuite/tests/deriving/should_fail/T2721.hs new file mode 100644 index 0000000000..f6485ce514 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2721.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving #-} + +-- Trac #2721 + +module T2721 where + +class C a where + type T a + foo :: a -> T a + +instance C Int where + type T Int = Int + foo = id + +newtype N = N Int deriving(C) diff --git a/testsuite/tests/deriving/should_fail/T2721.stderr b/testsuite/tests/deriving/should_fail/T2721.stderr new file mode 100644 index 0000000000..03339d3bfa --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2721.stderr @@ -0,0 +1,6 @@ +
+T2721.hs:15:28:
+ Can't make a derived instance of `C N'
+ (even with cunning newtype deriving):
+ the class has associated types
+ In the newtype declaration for `N'
diff --git a/testsuite/tests/deriving/should_fail/T2851.hs b/testsuite/tests/deriving/should_fail/T2851.hs new file mode 100644 index 0000000000..bc7239af0a --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2851.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeFamilies #-} +-- Test Trac #2851 + +module T2851 where + +type family F a :: * + +data D a = D (F a) + deriving (Show) diff --git a/testsuite/tests/deriving/should_fail/T2851.stderr b/testsuite/tests/deriving/should_fail/T2851.stderr new file mode 100644 index 0000000000..a2beb9869d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T2851.stderr @@ -0,0 +1,9 @@ + +T2851.hs:9:15: + No instance for (Show (F a)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Show (F a)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Show (D a)) diff --git a/testsuite/tests/deriving/should_fail/T3101.hs b/testsuite/tests/deriving/should_fail/T3101.hs new file mode 100644 index 0000000000..134694a4fe --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3101.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE RankNTypes #-} + +module T3101 where + +type family F a :: * + +data Boom = Boom (forall a. F a) + deriving Show diff --git a/testsuite/tests/deriving/should_fail/T3101.stderr b/testsuite/tests/deriving/should_fail/T3101.stderr new file mode 100644 index 0000000000..34f423daff --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3101.stderr @@ -0,0 +1,6 @@ + +T3101.hs:9:12: + Can't make a derived instance of `Show Boom': + Constructor `Boom' must have a Haskell-98 type + Possible fix: use a standalone deriving declaration instead + In the data type declaration for `Boom' diff --git a/testsuite/tests/deriving/should_fail/T3621.hs b/testsuite/tests/deriving/should_fail/T3621.hs new file mode 100644 index 0000000000..cd574eab81 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3621.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, FlexibleContexts, UndecidableInstances, StandaloneDeriving #-} +module T3621 where + +-- This one is ok, even though the deriving clause mentions 'a' +-- which is not a parameter of 'T' +class C a b +instance C a S +data S = MkS + +newtype T = MkT S deriving( C a ) + + +-- But this one fails, and should fail +class (Monad m) => MonadState s m | m -> s where + +newtype State s a = State { runState :: s -> (a, s) } +instance Monad (State s) where {} +instance MonadState s (State s) where {} + +newtype WrappedState s a = WS { runWS :: State s a } + deriving (Monad, MonadState state) +-- deriving (Monad) + +deriving instance (MonadState state (State s)) + => MonadState state (WrappedState s) + +-- ASSERT error +-- deriving instance (MonadState state (State s), Monad (WrappedState s)) +-- => MonadState s (WrappedState s) + + +-- We try +-- instance MonadState state (State state a) +-- => MonadState state (WrappedState state a) +-- +-- Superclass needs (Monad (WrappedState state a)) diff --git a/testsuite/tests/deriving/should_fail/T3621.stderr b/testsuite/tests/deriving/should_fail/T3621.stderr new file mode 100644 index 0000000000..dc9dc849ab --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3621.stderr @@ -0,0 +1,13 @@ + +T3621.hs:21:21: + Couldn't match type `s' with `state' + `s' is an unknown type variable + `state' is an unknown type variable + When using functional dependencies to combine + MonadState s (State s), + arising from the dependency `m -> s' + in the instance declaration at T3621.hs:18:10 + MonadState state (State s), + arising from the 'deriving' clause of a data type declaration + at T3621.hs:21:21-36 + When deriving the instance for (MonadState state (WrappedState s)) diff --git a/testsuite/tests/deriving/should_fail/T3833.hs b/testsuite/tests/deriving/should_fail/T3833.hs new file mode 100644 index 0000000000..d1196c4112 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3833.hs @@ -0,0 +1,9 @@ + +{-# LANGUAGE StandaloneDeriving #-} +-- {-# LANGUAGE GeneralizedNewtypeDeriving #-} + +import Data.Monoid + +newtype DecodeMap e = DecodeMap [e] + +deriving instance Monoid (DecodeMap e) diff --git a/testsuite/tests/deriving/should_fail/T3833.stderr b/testsuite/tests/deriving/should_fail/T3833.stderr new file mode 100644 index 0000000000..2d31cc1364 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3833.stderr @@ -0,0 +1,6 @@ + +T3833.hs:9:1: + Can't make a derived instance of `Monoid (DecodeMap e)': + `Monoid' is not a derivable class + Try -XGeneralizedNewtypeDeriving for GHC's newtype-deriving extension + In the stand-alone deriving instance for `Monoid (DecodeMap e)' diff --git a/testsuite/tests/deriving/should_fail/T3834.hs b/testsuite/tests/deriving/should_fail/T3834.hs new file mode 100644 index 0000000000..614170198e --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3834.hs @@ -0,0 +1,9 @@ + +{-# LANGUAGE StandaloneDeriving #-} + +class C a +instance C Int + +newtype T = T Int +deriving instance C T + diff --git a/testsuite/tests/deriving/should_fail/T3834.stderr b/testsuite/tests/deriving/should_fail/T3834.stderr new file mode 100644 index 0000000000..199b4bb799 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T3834.stderr @@ -0,0 +1,6 @@ + +T3834.hs:8:1: + Can't make a derived instance of `C T': + `C' is not a derivable class + Try -XGeneralizedNewtypeDeriving for GHC's newtype-deriving extension + In the stand-alone deriving instance for `C T' diff --git a/testsuite/tests/deriving/should_fail/T4528.hs b/testsuite/tests/deriving/should_fail/T4528.hs new file mode 100644 index 0000000000..23a8510d98 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T4528.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE GADTs, StandaloneDeriving #-} + +module T4528 where + +data Foo a where + A, B :: Foo Int + C :: Foo Bool + +deriving instance Enum (Foo a) +deriving instance Bounded (Foo a) + diff --git a/testsuite/tests/deriving/should_fail/T4528.stderr b/testsuite/tests/deriving/should_fail/T4528.stderr new file mode 100644 index 0000000000..8f008e8908 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T4528.stderr @@ -0,0 +1,14 @@ + +T4528.hs:9:1: + Can't make a derived instance of `Enum (Foo a)': + `Foo' must be an enumeration type + (an enumeration consists of one or more nullary, non-GADT constructors) + In the stand-alone deriving instance for `Enum (Foo a)' + +T4528.hs:10:1: + Can't make a derived instance of `Bounded (Foo a)': + `Foo' must be an enumeration type + (an enumeration consists of one or more nullary, non-GADT constructors) + or + `Foo' must have precisely one constructor + In the stand-alone deriving instance for `Bounded (Foo a)' diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T new file mode 100644 index 0000000000..8fa5e27e60 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/all.T @@ -0,0 +1,35 @@ + +test('drvfail001', normal, compile_fail, ['']) +test('drvfail002', normal, compile_fail, ['']) +test('drvfail003', normal, compile_fail, ['']) +test('drvfail004', normal, compile_fail, ['']) +test('drvfail005', normal, compile_fail, ['']) +test('drvfail006', reqlib('mtl'), compile_fail, ['']) +test('drvfail007', normal, compile_fail, ['']) +test('drvfail008', reqlib('mtl'), compile_fail, ['']) +test('drvfail009', normal, compile_fail, ['']) +test('drvfail010', normal, compile_fail, ['']) +test('drvfail011', normal, compile_fail, ['']) +test('drvfail012', normal, compile_fail, ['']) +test('drvfail013', normal, compile_fail, ['']) +test('drvfail014', normal, compile_fail, ['']) +test('drvfail015', normal, compile_fail, ['']) +test('drvfail016', + extra_clean(['drvfail016.hi-boot', 'drvfail016.o-boot']), + run_command, + ['$MAKE --no-print-directory -s drvfail016']) +test('T2394', normal, compile_fail, ['']) +test('T2604', normal, compile_fail, ['']) +test('T2701', normal, compile_fail, ['']) +test('T2851', normal, compile_fail, ['']) +test('T2721', normal, compile_fail, ['']) +test('T3101', normal, compile_fail, ['']) +test('T3621', normal, compile_fail, ['']) +test('drvfail-functor1', normal, compile_fail, ['']) +test('drvfail-functor2', normal, compile_fail, ['']) +test('drvfail-foldable-traversable1', normal, compile_fail, + ['']) +test('T3833', normal, compile_fail, ['']) +test('T3834', normal, compile_fail, ['']) +test('T4528', normal, compile_fail, ['']) + diff --git a/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.hs b/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.hs new file mode 100644 index 0000000000..ced3f98c63 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-} +module ShouldFail where + +import Data.Foldable +import Data.Traversable + +-- Derive Traversable without Functor +data Trivial1 a = Trivial1 a + deriving (Foldable,Traversable) + +-- Derive Traversable without Foldable +data Trivial2 a = Trivial2 a + deriving (Functor,Traversable) + +-- Foldable with function type +data Infinite a = Infinite (Int -> a) + deriving (Functor,Foldable,Traversable) + +-- Foldable with function type +data Cont r a = Cont ((a -> r) -> r) + deriving (Functor,Foldable,Traversable) diff --git a/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.stderr b/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.stderr new file mode 100644 index 0000000000..ecd20e8372 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-foldable-traversable1.stderr @@ -0,0 +1,38 @@ + +drvfail-foldable-traversable1.hs:9:23: + No instance for (Functor Trivial1) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Functor Trivial1) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Traversable Trivial1) + +drvfail-foldable-traversable1.hs:13:22: + No instance for (Foldable Trivial2) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Foldable Trivial2) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Traversable Trivial2) + +drvfail-foldable-traversable1.hs:17:22: + Can't make a derived instance of `Foldable Infinite': + Constructor `Infinite' must not contain function types + In the data type declaration for `Infinite' + +drvfail-foldable-traversable1.hs:17:31: + Can't make a derived instance of `Traversable Infinite': + Constructor `Infinite' must not contain function types + In the data type declaration for `Infinite' + +drvfail-foldable-traversable1.hs:21:22: + Can't make a derived instance of `Foldable (Cont r)': + Constructor `Cont' must not contain function types + In the data type declaration for `Cont' + +drvfail-foldable-traversable1.hs:21:31: + Can't make a derived instance of `Traversable (Cont r)': + Constructor `Cont' must not contain function types + In the data type declaration for `Cont' diff --git a/testsuite/tests/deriving/should_fail/drvfail-functor1.hs b/testsuite/tests/deriving/should_fail/drvfail-functor1.hs new file mode 100644 index 0000000000..94ebd925b8 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-functor1.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- Derive Functor without a DeriveFunctor language pragma + +data List a = Nil | Cons a (List a) + deriving Functor diff --git a/testsuite/tests/deriving/should_fail/drvfail-functor1.stderr b/testsuite/tests/deriving/should_fail/drvfail-functor1.stderr new file mode 100644 index 0000000000..d221f99f9d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-functor1.stderr @@ -0,0 +1,5 @@ +
+drvfail-functor1.hs:6:14:
+ Can't make a derived instance of `Functor List':
+ You need -XDeriveFunctor to derive an instance for this class
+ In the data type declaration for `List'
diff --git a/testsuite/tests/deriving/should_fail/drvfail-functor2.hs b/testsuite/tests/deriving/should_fail/drvfail-functor2.hs new file mode 100644 index 0000000000..7198755b80 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-functor2.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE DeriveFunctor, DatatypeContexts #-} +module ShouldFail where + +-- Derive Functor on a type that uses 'a' in the wrong places + +newtype InFunctionArgument a = InFunctionArgument (a -> Int) + deriving (Functor) + +newtype OnSecondArg a = OnSecondArg (Either a a) + deriving (Functor) + +-- Derive Functor on a type with no arguments + +newtype NoArguments = NoArguments Int + deriving (Functor) + +-- Derive Functor on a type with extra stupid-contraints on 'a' + +data Eq a => StupidConstraint a = StupidType a + deriving (Functor) + +-- A missing Functor instance + +data NoFunctor a = NoFunctor +data UseNoFunctor a = UseNoFunctor (NoFunctor a) + deriving (Functor) diff --git a/testsuite/tests/deriving/should_fail/drvfail-functor2.stderr b/testsuite/tests/deriving/should_fail/drvfail-functor2.stderr new file mode 100644 index 0000000000..7ce404666f --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail-functor2.stderr @@ -0,0 +1,32 @@ + +drvfail-functor2.hs:1:29: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +drvfail-functor2.hs:7:14: + Can't make a derived instance of `Functor InFunctionArgument': + Constructor `InFunctionArgument' must not use the type variable in a function argument + In the newtype declaration for `InFunctionArgument' + +drvfail-functor2.hs:10:14: + Can't make a derived instance of `Functor OnSecondArg': + Constructor `OnSecondArg' must not use the type variable in an argument other than the last + In the newtype declaration for `OnSecondArg' + +drvfail-functor2.hs:15:14: + Cannot derive well-kinded instance of form `Functor (NoArguments ...)' + Class `Functor' expects an argument of kind `* -> *' + In the newtype declaration for `NoArguments' + +drvfail-functor2.hs:20:14: + Can't make a derived instance of `Functor StupidConstraint': + Data type `StupidConstraint' must not have a class context (Eq a) + In the data type declaration for `StupidConstraint' + +drvfail-functor2.hs:26:14: + No instance for (Functor NoFunctor) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Functor NoFunctor) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Functor UseNoFunctor) diff --git a/testsuite/tests/deriving/should_fail/drvfail001.hs b/testsuite/tests/deriving/should_fail/drvfail001.hs new file mode 100644 index 0000000000..47447fb3e3 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail001.hs @@ -0,0 +1,26 @@ +{- From: Ian Bayley + Sent: Tuesday, June 29, 1999 3:39 PM + To: hugs-bugs@haskell.org + Subject: Show for higher-order nested datatypes + + + Is "deriving Show" meant to work for higher-order nested datatypes ? + Hugs hangs when loading in the following file: +-} + +module Foo where + +type SqMat a = SM Nil a + +data SM f a = ZeroS (f (f a)) | SuccS (SM (Cons f) a) + deriving Show + +-- Show (f (f a)), Show (SM (Cons f) a) => Show (SM f a) + +data Nil a = MkNil deriving Show + +data Cons f a = MkCons a (f a) + deriving Show + + + diff --git a/testsuite/tests/deriving/should_fail/drvfail001.stderr b/testsuite/tests/deriving/should_fail/drvfail001.stderr new file mode 100644 index 0000000000..a2a149594c --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail001.stderr @@ -0,0 +1,9 @@ + +drvfail001.hs:16:33: + No instance for (Show (f (f a))) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Show (f (f a))) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Show (SM f a)) diff --git a/testsuite/tests/deriving/should_fail/drvfail002.hs b/testsuite/tests/deriving/should_fail/drvfail002.hs new file mode 100644 index 0000000000..26a8f083d2 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail002.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE UndecidableInstances, + MultiParamTypeClasses, FunctionalDependencies #-} + +-- The Show instance for S would have form +-- instance X T c => Show S +-- which is hard to deal with. It sent GHC 5.01 into +-- an infinite loop; now it should be rejected. + +module ShouldFail where + +data T = T Integer + +class X a b | a -> b where + f :: a -> b + +instance X T c => Show T where + show _ = "" + +data S = S T deriving Show + diff --git a/testsuite/tests/deriving/should_fail/drvfail002.stderr b/testsuite/tests/deriving/should_fail/drvfail002.stderr new file mode 100644 index 0000000000..c174c69055 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail002.stderr @@ -0,0 +1,6 @@ + +drvfail002.hs:16:10: + Ambiguous constraint `X T c' + At least one of the forall'd type variables mentioned by the constraint + must be reachable from the type after the '=>' + In the instance declaration for `Show T' diff --git a/testsuite/tests/deriving/should_fail/drvfail002.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail002.stderr-hugs new file mode 100644 index 0000000000..b67a94ef5c --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail002.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail002.hs":18 - An instance of X T a is required to derive Show S diff --git a/testsuite/tests/deriving/should_fail/drvfail003.hs b/testsuite/tests/deriving/should_fail/drvfail003.hs new file mode 100644 index 0000000000..5d22dc1d4a --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail003.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE FlexibleContexts #-} +-- Made GHC 5.02.2 go into a loop when doing the +-- context inference for deriving. It only happened with +-- the -fglasgow-exts flag (it didn't diverge without), +-- so hopefully FlexibleContexts is the relevant extension. + +module ShouldFail where + +data Empty a = E +newtype Id a = I a +newtype Pair v w a = P ((v a), (w a)) +type Square a = Square_ Empty Id a +data Square_ v w a = + End (v (v a)) + | Zero (Square_ v (Pair w w) a) + | One (Square_ (Pair v w) (Pair w w) a) deriving Show diff --git a/testsuite/tests/deriving/should_fail/drvfail003.stderr b/testsuite/tests/deriving/should_fail/drvfail003.stderr new file mode 100644 index 0000000000..4aa98531b8 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail003.stderr @@ -0,0 +1,9 @@ + +drvfail003.hs:16:56: + No instance for (Show (v (v a))) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Show (v (v a))) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Show (Square_ v w a)) diff --git a/testsuite/tests/deriving/should_fail/drvfail003.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail003.stderr-hugs new file mode 100644 index 0000000000..0dab54095c --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail003.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail003.hs":13 - An instance of Show (Pair a b (Pair a b c)) is required to derive Show (Square_ a b c) diff --git a/testsuite/tests/deriving/should_fail/drvfail004.hs b/testsuite/tests/deriving/should_fail/drvfail004.hs new file mode 100644 index 0000000000..8716a5837f --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail004.hs @@ -0,0 +1,9 @@ +-- !!! deriving Ord without deriving Eq +-- +module ShouldFail where + +data Foo a b + = C1 a Int + | C2 b Double + deriving Ord + diff --git a/testsuite/tests/deriving/should_fail/drvfail004.stderr b/testsuite/tests/deriving/should_fail/drvfail004.stderr new file mode 100644 index 0000000000..d08f315cb7 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail004.stderr @@ -0,0 +1,9 @@ + +drvfail004.hs:8:12: + No instance for (Eq (Foo a b)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (Foo a b)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Ord (Foo a b)) diff --git a/testsuite/tests/deriving/should_fail/drvfail004.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail004.stderr-hugs new file mode 100644 index 0000000000..4370d8e96c --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail004.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "drvfail004.hs":6 - Cannot build superclass instance +*** Instance : Ord (Foo a b) +*** Context supplied : (Ord a, Ord b) +*** Required superclass : Eq (Foo a b) diff --git a/testsuite/tests/deriving/should_fail/drvfail005.hs b/testsuite/tests/deriving/should_fail/drvfail005.hs new file mode 100644 index 0000000000..ee44e2f343 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail005.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +data Test a = T a + deriving( Show a, Read ) diff --git a/testsuite/tests/deriving/should_fail/drvfail005.stderr b/testsuite/tests/deriving/should_fail/drvfail005.stderr new file mode 100644 index 0000000000..e27f3c1fd2 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail005.stderr @@ -0,0 +1,5 @@ +
+drvfail005.hs:4:13:
+ Can't make a derived instance of `Show a (Test a)':
+ `Show a' is not a class
+ In the data type declaration for `Test'
diff --git a/testsuite/tests/deriving/should_fail/drvfail006.hs b/testsuite/tests/deriving/should_fail/drvfail006.hs new file mode 100644 index 0000000000..0d8d1a95d9 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail006.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + +-- Testing the newtype-deriving stuff + +module ShouldFail where + +import Control.Monad.State + +newtype T a = T (StateT Int IO a) deriving( MonadState ) + -- Here MonadState takes two type params, + -- but exactly one is needed.
\ No newline at end of file diff --git a/testsuite/tests/deriving/should_fail/drvfail006.stderr b/testsuite/tests/deriving/should_fail/drvfail006.stderr new file mode 100644 index 0000000000..018291b6bb --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail006.stderr @@ -0,0 +1,6 @@ +
+drvfail006.hs:9:45:
+ Can't make a derived instance of `MonadState T'
+ (even with cunning newtype deriving):
+ `MonadState' does not have arity 1
+ In the newtype declaration for `T'
diff --git a/testsuite/tests/deriving/should_fail/drvfail006.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail006.stderr-hugs new file mode 100644 index 0000000000..b4c1c277a0 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail006.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail006.hs":9 - Cannot derive instances of class "MonadState" diff --git a/testsuite/tests/deriving/should_fail/drvfail007.hs b/testsuite/tests/deriving/should_fail/drvfail007.hs new file mode 100644 index 0000000000..74f9f033d3 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail007.hs @@ -0,0 +1,4 @@ +-- !!! buggy deriving with function type, reported by Sigbjorn Finne +module ShouldFail where + +data Foo = Foo (Int -> Int) deriving Eq diff --git a/testsuite/tests/deriving/should_fail/drvfail007.stderr b/testsuite/tests/deriving/should_fail/drvfail007.stderr new file mode 100644 index 0000000000..7dc7124fd1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail007.stderr @@ -0,0 +1,9 @@ + +drvfail007.hs:4:38: + No instance for (Eq (Int -> Int)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (Int -> Int)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Eq Foo) diff --git a/testsuite/tests/deriving/should_fail/drvfail007.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail007.stderr-hugs new file mode 100644 index 0000000000..3285aeeb78 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail007.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail007.hs":4 - An instance of Eq (Int -> Int) is required to derive Eq Foo diff --git a/testsuite/tests/deriving/should_fail/drvfail008.hs b/testsuite/tests/deriving/should_fail/drvfail008.hs new file mode 100644 index 0000000000..af8628b4d5 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail008.hs @@ -0,0 +1,14 @@ +-- Should fail without GeneralizedNewtypeDeriving +-- Succeeds with GeneralizedNewtypeDeriving + +module ShouldFail where + +import Control.Monad.State + +data S = S Int + +newtype M a = M (StateT S IO a) deriving( Monad ) + + + + diff --git a/testsuite/tests/deriving/should_fail/drvfail008.stderr b/testsuite/tests/deriving/should_fail/drvfail008.stderr new file mode 100644 index 0000000000..9b56dfb1d7 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail008.stderr @@ -0,0 +1,6 @@ +
+drvfail008.hs:10:43:
+ Can't make a derived instance of `Monad M':
+ `Monad' is not a derivable class
+ Try -XGeneralizedNewtypeDeriving for GHC's newtype-deriving extension
+ In the newtype declaration for `M'
diff --git a/testsuite/tests/deriving/should_fail/drvfail009.hs b/testsuite/tests/deriving/should_fail/drvfail009.hs new file mode 100644 index 0000000000..06155c38a1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail009.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses #-} + +-- Various newtype-deriving failures + +module ShouldFail where + + +class C a b + +newtype T1 = T1 Int deriving( C ) + -- Wrong arity + +newtype T2 = T2 Int deriving( Monad ) + -- Type constructor has wrong kind + +newtype T3 a = T3 Int deriving( Monad ) + -- Rep type has wrong kind + +newtype T4 a = T4 (Either a a) deriving( Monad ) + -- Eta fails diff --git a/testsuite/tests/deriving/should_fail/drvfail009.stderr b/testsuite/tests/deriving/should_fail/drvfail009.stderr new file mode 100644 index 0000000000..7594baef39 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail009.stderr @@ -0,0 +1,23 @@ +
+drvfail009.hs:10:31:
+ Can't make a derived instance of `C T1'
+ (even with cunning newtype deriving):
+ `C' does not have arity 1
+ In the newtype declaration for `T1'
+
+drvfail009.hs:13:31:
+ Cannot derive well-kinded instance of form `Monad (T2 ...)'
+ Class `Monad' expects an argument of kind `* -> *'
+ In the newtype declaration for `T2'
+
+drvfail009.hs:16:33:
+ Can't make a derived instance of `Monad T3'
+ (even with cunning newtype deriving):
+ cannot eta-reduce the representation type enough
+ In the newtype declaration for `T3'
+
+drvfail009.hs:19:42:
+ Can't make a derived instance of `Monad T4'
+ (even with cunning newtype deriving):
+ cannot eta-reduce the representation type enough
+ In the newtype declaration for `T4'
diff --git a/testsuite/tests/deriving/should_fail/drvfail009.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail009.stderr-hugs new file mode 100644 index 0000000000..79fba84f61 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail009.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail009.hs":10 - Cannot derive instances of class "C" diff --git a/testsuite/tests/deriving/should_fail/drvfail010.hs b/testsuite/tests/deriving/should_fail/drvfail010.hs new file mode 100644 index 0000000000..efecf07cf1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail010.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DeriveDataTypeable #-} + +module ShouldFail where +import Data.Typeable + +data A a b c d e f g h i j = A deriving (Typeable) + -- Too many args + +data B a b = B (a b) deriving (Typeable) + -- Non type-kind args
\ No newline at end of file diff --git a/testsuite/tests/deriving/should_fail/drvfail010.stderr b/testsuite/tests/deriving/should_fail/drvfail010.stderr new file mode 100644 index 0000000000..a61fb4892f --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail010.stderr @@ -0,0 +1,11 @@ + +drvfail010.hs:6:42: + Can't make a derived instance of + `Typeable (A a b c d e f g h i j)': + `A' must have 7 or fewer arguments + In the data type declaration for `A' + +drvfail010.hs:9:32: + Can't make a derived instance of `Typeable (B a b)': + `B' must only have arguments of kind `*' + In the data type declaration for `B' diff --git a/testsuite/tests/deriving/should_fail/drvfail010.stderr-hugs b/testsuite/tests/deriving/should_fail/drvfail010.stderr-hugs new file mode 100644 index 0000000000..f6479975a5 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail010.stderr-hugs @@ -0,0 +1 @@ +ERROR "drvfail010.hs":6 - Cannot derive instances of class "Typeable" diff --git a/testsuite/tests/deriving/should_fail/drvfail011.hs b/testsuite/tests/deriving/should_fail/drvfail011.hs new file mode 100644 index 0000000000..33e35c4d83 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail011.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneDeriving #-} + +module ShouldFail where + +data T a = T1 a | T2 + +-- This fails as we need an (Eq a) context +deriving instance Eq (T a) diff --git a/testsuite/tests/deriving/should_fail/drvfail011.stderr b/testsuite/tests/deriving/should_fail/drvfail011.stderr new file mode 100644 index 0000000000..80e486628b --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail011.stderr @@ -0,0 +1,10 @@ + +drvfail011.hs:8:1: + No instance for (Eq a) + arising from a use of `==' + In the expression: ((a1 == b1)) + In an equation for `==': == (T1 a1) (T1 b1) = ((a1 == b1)) + When typechecking the code for `==' + in a standalone derived instance for `Eq (T a)': + To see the code I am typechecking, use -ddump-deriv + In the instance declaration for `Eq (T a)' diff --git a/testsuite/tests/deriving/should_fail/drvfail012.hs b/testsuite/tests/deriving/should_fail/drvfail012.hs new file mode 100644 index 0000000000..4a073bbed1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail012.hs @@ -0,0 +1,8 @@ +-- Trac #1608 + +module ShouldFail where + +newtype Ego a = Ego a deriving (Ord) + +f :: Ord a => Ego a -> Ego a -> Bool +f e1 e2 = e1 < e2 diff --git a/testsuite/tests/deriving/should_fail/drvfail012.stderr b/testsuite/tests/deriving/should_fail/drvfail012.stderr new file mode 100644 index 0000000000..22fac4887d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail012.stderr @@ -0,0 +1,9 @@ + +drvfail012.hs:5:33: + No instance for (Eq (Ego a)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (Ego a)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Ord (Ego a)) diff --git a/testsuite/tests/deriving/should_fail/drvfail013.hs b/testsuite/tests/deriving/should_fail/drvfail013.hs new file mode 100644 index 0000000000..d8a7322dba --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail013.hs @@ -0,0 +1,6 @@ + +-- Test for trac #1588: unrequested generalized newtype deriving? + +newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } deriving Eq + +data MaybeT' m a = MaybeT' { runMaybeT' :: m (Maybe a) } deriving Eq diff --git a/testsuite/tests/deriving/should_fail/drvfail013.stderr b/testsuite/tests/deriving/should_fail/drvfail013.stderr new file mode 100644 index 0000000000..94927cd790 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail013.stderr @@ -0,0 +1,18 @@ + +drvfail013.hs:4:70: + No instance for (Eq (m (Maybe a))) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (m (Maybe a))) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Eq (MaybeT m a)) + +drvfail013.hs:6:70: + No instance for (Eq (m (Maybe a))) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (m (Maybe a))) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Eq (MaybeT' m a)) diff --git a/testsuite/tests/deriving/should_fail/drvfail014.hs b/testsuite/tests/deriving/should_fail/drvfail014.hs new file mode 100644 index 0000000000..9039332f29 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail014.hs @@ -0,0 +1,13 @@ +{-# OPTIONS_GHC -XDeriveDataTypeable -XStandaloneDeriving #-} + +-- See Trac #1825 + +module ShouldFail where +import Data.Typeable + +data T1 a = T1 a deriving( Typeable1 ) + +data T2 a b = T2 a b + +deriving instance (Typeable a, Typeable b) => Typeable (T2 a b) + -- c.f. drv021.hs diff --git a/testsuite/tests/deriving/should_fail/drvfail014.stderr b/testsuite/tests/deriving/should_fail/drvfail014.stderr new file mode 100644 index 0000000000..865a78c44e --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail014.stderr @@ -0,0 +1,9 @@ + +drvfail014.hs:8:28: + Use deriving( Typeable ) on a data type declaration + In the data type declaration for `T1' + +drvfail014.hs:12:1: + Derived typeable instance must be of form (Typeable2 T2) + In the stand-alone deriving instance for + `(Typeable a, Typeable b) => Typeable (T2 a b)' diff --git a/testsuite/tests/deriving/should_fail/drvfail015.hs b/testsuite/tests/deriving/should_fail/drvfail015.hs new file mode 100644 index 0000000000..32d6134d34 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail015.hs @@ -0,0 +1,13 @@ +{-# OPTIONS_GHC -XStandaloneDeriving #-} + +module ShouldFail where + +import System.IO( Handle ) + + +-- T is a synonym +type T = Int +deriving instance Eq T + +-- Handle is abstract +deriving instance Eq Handle diff --git a/testsuite/tests/deriving/should_fail/drvfail015.stderr b/testsuite/tests/deriving/should_fail/drvfail015.stderr new file mode 100644 index 0000000000..a7d8ac6cf1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail015.stderr @@ -0,0 +1,13 @@ +
+drvfail015.hs:10:19:
+ Illegal instance declaration for `Eq T'
+ (All instance types must be of the form (T t1 ... tn)
+ where T is not a synonym.
+ Use -XTypeSynonymInstances if you want to disable this.)
+ In the stand-alone deriving instance for `Eq T'
+
+drvfail015.hs:13:1:
+ Can't make a derived instance of `Eq Handle':
+ The data constructors of `Handle' are not all in scope
+ so you cannot derive an instance for it
+ In the stand-alone deriving instance for `Eq Handle'
diff --git a/testsuite/tests/deriving/should_fail/drvfail015.stderr-7.0 b/testsuite/tests/deriving/should_fail/drvfail015.stderr-7.0 new file mode 100644 index 0000000000..9f0166e9cd --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail015.stderr-7.0 @@ -0,0 +1,12 @@ + +drvfail015.hs:10:19: + Illegal instance declaration for `Eq T' + (All instance types must be of the form (T t1 ... tn) + where T is not a synonym. + Use -XTypeSynonymInstances if you want to disable this.) + In the stand-alone deriving instance for `Eq T' + +drvfail015.hs:13:1: + The data constructors of `Handle' are not all in scope + so you cannot derive an instance for it + In the stand-alone deriving instance for `Eq Handle' diff --git a/testsuite/tests/deriving/should_fail/drvfail016.hs-boot b/testsuite/tests/deriving/should_fail/drvfail016.hs-boot new file mode 100644 index 0000000000..b3a388f736 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail016.hs-boot @@ -0,0 +1,7 @@ + +-- trac #2449 + +module A where + +data D + deriving Show diff --git a/testsuite/tests/deriving/should_fail/drvfail016.stderr b/testsuite/tests/deriving/should_fail/drvfail016.stderr new file mode 100644 index 0000000000..1bcb7363b1 --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail016.stderr @@ -0,0 +1,4 @@ + +drvfail016.hs-boot:6:1: + Deriving not permitted in hs-boot file + Use an instance declaration instead diff --git a/testsuite/tests/deriving/should_fail/drvfail016.stdout b/testsuite/tests/deriving/should_fail/drvfail016.stdout new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/testsuite/tests/deriving/should_fail/drvfail016.stdout @@ -0,0 +1 @@ +1 |