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/typecheck/should_fail | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
574 files changed, 6357 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.hs b/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.hs new file mode 100644 index 0000000000..505eddcad1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE FlexibleContexts #-}
+
+module FailDueToGivenOverlapping where
+
+class C a where
+
+class D a where
+ dop :: a -> ()
+
+
+instance C a => D [a]
+
+-- should succeed since we can't learn anything more for 'a'
+foo :: (C a, D [Int]) => a -> ()
+foo x = dop [x]
+
+
+class E a where
+ eop :: a -> ()
+
+instance E [a] where
+ eop = undefined
+
+-- should fail since we can never be sure that we learnt
+-- everything about the free unification variable.
+bar :: E [Int] => () -> ()
+bar _ = eop [undefined]
diff --git a/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.stderr b/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.stderr new file mode 100644 index 0000000000..10db900878 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/FailDueToGivenOverlapping.stderr @@ -0,0 +1,13 @@ +
+FailDueToGivenOverlapping.hs:27:9:
+ Overlapping instances for E [t0]
+ arising from a use of `eop'
+ Matching instances:
+ instance E [a] -- Defined at FailDueToGivenOverlapping.hs:21:10-14
+ Matching givens (or their superclasses):
+ (E [Int])
+ bound by the type signature for bar :: E [Int] => () -> ()
+ at FailDueToGivenOverlapping.hs:27:1-23
+ (The choice depends on the instantiation of `t0')
+ In the expression: eop [undefined]
+ In an equation for `bar': bar _ = eop [undefined]
diff --git a/testsuite/tests/typecheck/should_fail/FrozenErrorTests.hs b/testsuite/tests/typecheck/should_fail/FrozenErrorTests.hs new file mode 100644 index 0000000000..bea5495518 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/FrozenErrorTests.hs @@ -0,0 +1,56 @@ +{-# LANGUAGE RankNTypes, GADTs, TypeFamilies #-}
+module Test where
+
+
+data T a where
+ MkT :: a -> T a
+ MkT2 :: forall a b. (b ~ T b) => b -> T a
+ MkT3 :: forall a. (a ~ Bool) => T a
+-- Occurs checks in givens
+foo :: forall a. (a ~ T a) => a -> a
+foo x = x
+
+blah x = case x of
+ MkT2 y -> ()
+
+-- Mismatches in givens
+bloh :: T Int -> ()
+bloh x = case x of
+ MkT3 -> ()
+
+type family F a b
+type family G a b
+type instance F a Bool = a
+type instance G a Char = a
+
+goo1 :: forall a b. (F a b ~ [a]) => b -> a -> a
+goo1 = undefined
+
+goo2 :: forall a. G a Char ~ [Int] => a -> a
+goo2 = undefined
+
+-- Just an occurs check
+test1 = goo1 False undefined
+
+-- A frozen occurs check, now transformed to decomposition error
+test2 = goo2 (goo1 False undefined)
+test3 = goo1 False (goo2 undefined)
+
+
+-- A frozen occurs check, now transformed to both a decomposition and occurs check
+data M a where
+ M :: M a
+data T2 a b where
+ T2 :: T2 a b
+
+goo3 :: forall a b. F a b ~ T2 (M a) a => b -> a -> a
+goo3 = undefined
+
+goo4 :: forall a c. G a Char ~ T2 (T2 c c) c => a -> a
+goo4 = undefined
+
+test4 = goo4 (goo3 False undefined)
+test5 = goo3 False (goo4 undefined)
+
+
+
diff --git a/testsuite/tests/typecheck/should_fail/FrozenErrorTests.stderr b/testsuite/tests/typecheck/should_fail/FrozenErrorTests.stderr new file mode 100644 index 0000000000..de552764d1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/FrozenErrorTests.stderr @@ -0,0 +1,73 @@ + +FrozenErrorTests.hs:11:1: + Couldn't match type `a' with `T a' + `a' is a rigid type variable bound by + the type signature for foo :: a ~ T a => a -> a + at FrozenErrorTests.hs:11:1 + Inaccessible code in + the type signature for foo :: a ~ T a => a -> a + +FrozenErrorTests.hs:14:12: + Couldn't match type `b' with `T b' + `b' is a rigid type variable bound by + a pattern with constructor + MkT2 :: forall a b. b ~ T b => b -> T a, + in a case alternative + at FrozenErrorTests.hs:14:12 + Inaccessible code in + a pattern with constructor + MkT2 :: forall a b. b ~ T b => b -> T a, + in a case alternative + In the pattern: MkT2 y + In a case alternative: MkT2 y -> () + In the expression: case x of { MkT2 y -> () } + +FrozenErrorTests.hs:19:12: + Couldn't match type `Int' with `Bool' + Inaccessible code in + a pattern with constructor + MkT3 :: forall a. a ~ Bool => T a, + in a case alternative + In the pattern: MkT3 + In a case alternative: MkT3 -> () + In the expression: case x of { MkT3 -> () } + +FrozenErrorTests.hs:33:9: + Occurs check: cannot construct the infinite type: a0 = [a0] + In the expression: goo1 False undefined + In an equation for `test1': test1 = goo1 False undefined + +FrozenErrorTests.hs:36:15: + Couldn't match type `[Int]' with `[[Int]]' + In the first argument of `goo2', namely `(goo1 False undefined)' + In the expression: goo2 (goo1 False undefined) + In an equation for `test2': test2 = goo2 (goo1 False undefined) + +FrozenErrorTests.hs:37:9: + Couldn't match type `Int' with `[Int]' + In the expression: goo1 False (goo2 undefined) + In an equation for `test3': test3 = goo1 False (goo2 undefined) + +FrozenErrorTests.hs:52:15: + Couldn't match type `T2 (T2 c0 c0) c0' + with `T2 (M (T2 (T2 c0 c0) c0)) (T2 (T2 c0 c0) c0)' + In the first argument of `goo4', namely `(goo3 False undefined)' + In the expression: goo4 (goo3 False undefined) + In an equation for `test4': test4 = goo4 (goo3 False undefined) + +FrozenErrorTests.hs:53:9: + Occurs check: cannot construct the infinite type: + c0 = T2 (T2 c0 c0) c0 + In the expression: goo3 False (goo4 undefined) + In an equation for `test5': test5 = goo3 False (goo4 undefined) + +FrozenErrorTests.hs:53:9: + Occurs check: cannot construct the infinite type: + c0 = T2 (T2 c0 c0) c0 + In the expression: goo3 False (goo4 undefined) + In an equation for `test5': test5 = goo3 False (goo4 undefined) + +FrozenErrorTests.hs:53:9: + Couldn't match type `T2 c0' with `M' + In the expression: goo3 False (goo4 undefined) + In an equation for `test5': test5 = goo3 False (goo4 undefined) diff --git a/testsuite/tests/typecheck/should_fail/IPFail.hs b/testsuite/tests/typecheck/should_fail/IPFail.hs new file mode 100644 index 0000000000..1c897eb8cb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/IPFail.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE ImplicitParams #-} + +module IPFail where + +f0 :: (?x :: Int) => () -> Bool +f0 () = let ?x = 5 in ?x diff --git a/testsuite/tests/typecheck/should_fail/IPFail.stderr b/testsuite/tests/typecheck/should_fail/IPFail.stderr new file mode 100644 index 0000000000..7d0d8980af --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/IPFail.stderr @@ -0,0 +1,13 @@ + +IPFail.hs:6:18: + Could not deduce (Num Bool) arising from the literal `5' + from the context (?x::Int) + bound by the type signature for f0 :: (?x::Int) => () -> Bool + at IPFail.hs:6:1-24 + Possible fix: + add (Num Bool) to the context of + the type signature for f0 :: (?x::Int) => () -> Bool + or add an instance declaration for (Num Bool) + In the expression: 5 + In the expression: let ?x = 5 in ?x + In an equation for `f0': f0 () = let ?x = 5 in ?x diff --git a/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs new file mode 100644 index 0000000000..4a79e69ed6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs @@ -0,0 +1,44 @@ +{-# LANGUAGE TypeFamilies, MultiParamTypeClasses
+ , FlexibleContexts, FlexibleInstances, UndecidableInstances
+ , TypeSynonymInstances, GeneralizedNewtypeDeriving
+ , OverlappingInstances
+ #-}
+
+module LongWayOverlapping where
+
+
+class M a where
+
+class M a => XMLG a
+
+instance M [a]
+
+instance XMLG [m] where -- Generates an implication wanted: forall m. M [m]
+
+class M a => EmbAsChild a b where
+ emb :: b -> [a]
+
+
+instance EmbAsChild [Char] Bool where
+ emb _ = emb 'c'
+
+
+ -- This one generates an unsolvable EmbAsChild [Char] Char
+
+-- Original problem is:
+-- [w] EmbAsChild [Char] Char
+-- [w] forall m. M [m]
+-- Now, by converting the wanted to given and pushing it inside the implication
+-- we have the following:
+-- [g] EmbAsChild [Char] Char
+-- [g] M [Char] <~~ The superclass of the first given!
+-- [w] M [m]
+-- And now OOPS we can't solve M [m] because we are supposed to delay our choice
+-- as much as possible!
+
+-- DV:
+-- One possible solution is to STOP PUSHING wanteds as givens inside an implication
+-- in a checking context. I think it's the best thing to do and I've implemented it.
+
+-- In inference mode that's ok and the error message is very comprehensible, see
+-- test case PushedInFlatsOverlap.hs
diff --git a/testsuite/tests/typecheck/should_fail/LongWayOverlapping.stderr b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.stderr new file mode 100644 index 0000000000..7cc45560c9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.stderr @@ -0,0 +1,9 @@ +
+LongWayOverlapping.hs:23:11:
+ No instance for (EmbAsChild [Char] Char)
+ arising from a use of `emb'
+ Possible fix:
+ add an instance declaration for (EmbAsChild [Char] Char)
+ In the expression: emb 'c'
+ In an equation for `emb': emb _ = emb 'c'
+ In the instance declaration for `EmbAsChild [Char] Bool'
diff --git a/testsuite/tests/typecheck/should_fail/Makefile b/testsuite/tests/typecheck/should_fail/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/typecheck/should_fail/SCLoop.hs b/testsuite/tests/typecheck/should_fail/SCLoop.hs new file mode 100644 index 0000000000..f3f6a20bc4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/SCLoop.hs @@ -0,0 +1,55 @@ +{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
+
+-- This is a superclass loop test
+-- It should fail with a type error, but
+-- it's all too easy to succeed with a bogus recursive dictionary
+
+module SCLoop where
+
+class SC a where
+ f :: a -> ()
+
+class SC a => A a b where
+ op :: a -> b -> ()
+ op x _ = f x
+
+instance A a b => A a [b]
+-- dfun1 :: \d::(A a b) -> DA (sc d)
+
+instance SC a => A a (Maybe b)
+-- dfun2 :: \d::SC a -> DA d
+
+foo = op () ([Just True])
+
+{- Here is the explanation:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[Wanted] d1 : (A () [Maybe Bool])
+~~~> d1 := dfun1 d2
+[Wanted] d2 : (A () (Maybe Bool))
+~~~> d2 := dfun2 d3
+[Wanted] d3 : SC ()
+[Derived] d4 : SC () d4 := sc d1
+~~~>
+ d3 := sc d1
+ isGoodRecEv will check:
+ d3 == sc d1
+ == sc (dfun1 d2)
+ == sc (dfun1 (dfun2 d3) ==> PASSES! (gravity = 1)
+ This is BAD BAD BAD, because we get a loop
+
+ If we had inlined the definitions:
+ d3 == sc d1
+ == sc (DA (sc d2))
+ == sc (DA (sc (DA d3))) ==> DOES NOT! (gravity = 0)
+
+We should get "No instance for SC ()"
+-}
+
+
+
+
+
+
+
+
diff --git a/testsuite/tests/typecheck/should_fail/SCLoop.stderr b/testsuite/tests/typecheck/should_fail/SCLoop.stderr new file mode 100644 index 0000000000..277b84a7b9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/SCLoop.stderr @@ -0,0 +1,7 @@ + +SCLoop.hs:22:7: + No instance for (SC ()) + arising from a use of `op' + Possible fix: add an instance declaration for (SC ()) + In the expression: op () ([Just True]) + In an equation for `foo': foo = op () ([Just True]) diff --git a/testsuite/tests/typecheck/should_fail/T1595.hs b/testsuite/tests/typecheck/should_fail/T1595.hs new file mode 100644 index 0000000000..fae0192c1e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1595.hs @@ -0,0 +1,13 @@ +-- +-- Check that we produce only one error message for each type +-- signature. See ticket #1595. +-- + +module T1595 where + +foo1, bar1 :: DoesNotExist +foo1 = undefined +bar1 = undefined + +class Test a where + foo2, bar2 :: a -> DoesNotExist diff --git a/testsuite/tests/typecheck/should_fail/T1595.stderr b/testsuite/tests/typecheck/should_fail/T1595.stderr new file mode 100644 index 0000000000..d3f665c15a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1595.stderr @@ -0,0 +1,6 @@ + +T1595.hs:8:15: + Not in scope: type constructor or class `DoesNotExist' + +T1595.hs:13:22: + Not in scope: type constructor or class `DoesNotExist' diff --git a/testsuite/tests/typecheck/should_fail/T1633.hs b/testsuite/tests/typecheck/should_fail/T1633.hs new file mode 100644 index 0000000000..3fff8f2540 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1633.hs @@ -0,0 +1,6 @@ +-- This just tests what the kind error message looks like +-- Trac #1633 + +module T1633 where + +instance Functor Bool diff --git a/testsuite/tests/typecheck/should_fail/T1633.stderr b/testsuite/tests/typecheck/should_fail/T1633.stderr new file mode 100644 index 0000000000..8b3e8fd8a2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1633.stderr @@ -0,0 +1,6 @@ + +T1633.hs:6:18: + Kind mis-match + The first argument of `Functor' should have kind `* -> *', + but `Bool' has kind `*' + In the instance declaration for `Functor Bool' diff --git a/testsuite/tests/typecheck/should_fail/T1899.hs b/testsuite/tests/typecheck/should_fail/T1899.hs new file mode 100644 index 0000000000..a49b647be7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1899.hs @@ -0,0 +1,16 @@ +-- Test for Trac #1899 + +module T1899 where + + data Constraint a = Formula [[Proposition a]] + data Proposition a = Prop a + | Auxiliary [Proposition a] + + transRHS :: [a] -> Int -> Constraint a + transRHS varSet b = + if b < 0 + then Formula [[Prop (Auxiliary undefined)]] + else Formula $ + [[Prop (Auxiliary varSet), + Prop (Auxiliary varSet)] + ] diff --git a/testsuite/tests/typecheck/should_fail/T1899.stderr b/testsuite/tests/typecheck/should_fail/T1899.stderr new file mode 100644 index 0000000000..4769b2d96c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T1899.stderr @@ -0,0 +1,15 @@ + +T1899.hs:13:13: + Couldn't match type `a' with `Proposition a0' + `a' is a rigid type variable bound by + the type signature for transRHS :: [a] -> Int -> Constraint a + at T1899.hs:10:2 + Expected type: Constraint a + Actual type: Constraint (Proposition a0) + In the expression: + Formula $ [[Prop (Auxiliary varSet), Prop (Auxiliary varSet)]] + In the expression: + if b < 0 then + Formula [[Prop (Auxiliary undefined)]] + else Formula + $ [[Prop (Auxiliary varSet), Prop (Auxiliary varSet)]] diff --git a/testsuite/tests/typecheck/should_fail/T2126.hs b/testsuite/tests/typecheck/should_fail/T2126.hs new file mode 100644 index 0000000000..4ef3037512 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2126.hs @@ -0,0 +1,5 @@ +-- Trac #2126
+
+module Foo where
+
+newtype X
diff --git a/testsuite/tests/typecheck/should_fail/T2126.stderr b/testsuite/tests/typecheck/should_fail/T2126.stderr new file mode 100644 index 0000000000..2facb189a9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2126.stderr @@ -0,0 +1,4 @@ + +T2126.hs:5:1: + A newtype must have exactly one constructor, but `X' has none + In the newtype declaration for `X' diff --git a/testsuite/tests/typecheck/should_fail/T2307.hs b/testsuite/tests/typecheck/should_fail/T2307.hs new file mode 100644 index 0000000000..321c2d5641 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2307.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + OverlappingInstances, UndecidableInstances, + IncoherentInstances, + FlexibleInstances #-} + +-- Trac #2307 + +module ShouldFail where + + class C a b c | a -> b, a -> c + instance C Int (Maybe String) Float + instance C Int (Maybe Bool) Double diff --git a/testsuite/tests/typecheck/should_fail/T2307.stderr b/testsuite/tests/typecheck/should_fail/T2307.stderr new file mode 100644 index 0000000000..0ca572dbd1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2307.stderr @@ -0,0 +1,7 @@ + +T2307.hs:11:11: + Functional dependencies conflict between instance declarations: + instance [incoherent] C Int (Maybe String) Float + -- Defined at T2307.hs:11:11-36 + instance [incoherent] C Int (Maybe Bool) Double + -- Defined at T2307.hs:12:11-37 diff --git a/testsuite/tests/typecheck/should_fail/T2414.hs b/testsuite/tests/typecheck/should_fail/T2414.hs new file mode 100644 index 0000000000..fba628db27 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2414.hs @@ -0,0 +1,9 @@ +-- Test for Trac #2414 +-- Should provoke an occurs-check error + +module ShouldFail where + +unfoldr :: (b -> Maybe (Bool, b)) -> Bool +unfoldr = unfoldr + +f = unfoldr Just diff --git a/testsuite/tests/typecheck/should_fail/T2414.stderr b/testsuite/tests/typecheck/should_fail/T2414.stderr new file mode 100644 index 0000000000..030bf6e52a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2414.stderr @@ -0,0 +1,7 @@ + +T2414.hs:9:13: + Occurs check: cannot construct the infinite type: b0 = (Bool, b0) + Expected type: b0 -> Maybe (Bool, b0) + Actual type: b0 -> Maybe b0 + In the first argument of `unfoldr', namely `Just' + In the expression: unfoldr Just diff --git a/testsuite/tests/typecheck/should_fail/T2538.hs b/testsuite/tests/typecheck/should_fail/T2538.hs new file mode 100644 index 0000000000..11d9c479b5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2538.hs @@ -0,0 +1,13 @@ + +-- Trac #2538 +module ShouldFail where +import Data.Ix + +f :: (Eq a => a -> a) -> Int +f = error "urk" + +g :: [Eq a => a -> a] -> Int +g = error "urk" + +h :: Ix (Eq a => a -> a) => Int +h = error "urk" diff --git a/testsuite/tests/typecheck/should_fail/T2538.stderr b/testsuite/tests/typecheck/should_fail/T2538.stderr new file mode 100644 index 0000000000..e4e9a7551a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2538.stderr @@ -0,0 +1,14 @@ +
+T2538.hs:6:1:
+ Illegal polymorphic or qualified type: Eq a => a -> a
+ Perhaps you intended to use -XRankNTypes or -XRank2Types
+ In the type signature for `f': f :: (Eq a => a -> a) -> Int
+
+T2538.hs:9:1:
+ Illegal polymorphic or qualified type: Eq a => a -> a
+ Perhaps you intended to use -XImpredicativeTypes
+ In the type signature for `g': g :: [Eq a => a -> a] -> Int
+
+T2538.hs:12:1:
+ Illegal polymorphic or qualified type: Eq a => a -> a
+ In the type signature for `h': h :: Ix (Eq a => a -> a) => Int
diff --git a/testsuite/tests/typecheck/should_fail/T2688.hs b/testsuite/tests/typecheck/should_fail/T2688.hs new file mode 100644 index 0000000000..6897e07b76 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2688.hs @@ -0,0 +1,8 @@ +{-# OPTIONS_GHC -XFunctionalDependencies -XMultiParamTypeClasses #-} + +module T2688 where + +class VectorSpace v s | v -> s where + (*^) :: s -> v -> v + (^/) :: v -> s -> v + v ^/ s = v *^ (1/s) diff --git a/testsuite/tests/typecheck/should_fail/T2688.stderr b/testsuite/tests/typecheck/should_fail/T2688.stderr new file mode 100644 index 0000000000..de91620078 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2688.stderr @@ -0,0 +1,13 @@ + +T2688.hs:8:22: + Could not deduce (s ~ v) + from the context (VectorSpace v s) + bound by the class declaration for `VectorSpace' + at T2688.hs:(5,1)-(8,23) + `s' is a rigid type variable bound by + the class declaration for `VectorSpace' at T2688.hs:5:21 + `v' is a rigid type variable bound by + the class declaration for `VectorSpace' at T2688.hs:5:19 + In the second argument of `(/)', namely `s' + In the second argument of `(*^)', namely `(1 / s)' + In the expression: v *^ (1 / s) diff --git a/testsuite/tests/typecheck/should_fail/T2714.hs b/testsuite/tests/typecheck/should_fail/T2714.hs new file mode 100644 index 0000000000..80f838c37c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2714.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE ScopedTypeVariables #-}
+
+-- Trac #2714
+
+module T2714 where
+
+f :: ((a -> b) -> b) -> (forall c. c -> a)
+f = ffmap
+
+ffmap :: Functor f => (p->q) -> f p -> f q
+ffmap = error "urk"
+
+{-
+ a ~ f q
+ c ~ f p
+ (p->q) ~ (a->b) -> b
+
+ =>
+ a ~ f q
+ c ~ f p
+ p ~ a->b
+ q ~ b
+ =>
+ a ~ f b
+ c ~ f (a->b)
+-}
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/T2714.stderr b/testsuite/tests/typecheck/should_fail/T2714.stderr new file mode 100644 index 0000000000..da355fc738 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2714.stderr @@ -0,0 +1,22 @@ + +T2714.hs:8:5: + Couldn't match type `a' with `f0 b' + `a' is a rigid type variable bound by + the type signature for f :: ((a -> b) -> b) -> forall c. c -> a + at T2714.hs:8:1 + Expected type: ((a -> b) -> b) -> c -> a + Actual type: ((a -> b) -> b) -> f0 (a -> b) -> f0 b + In the expression: ffmap + In an equation for `f': f = ffmap + +T2714.hs:8:5: + Couldn't match type `c' with `f0 (f0 b -> b)' + `c' is a rigid type variable bound by + the type signature for f :: ((a -> b) -> b) -> c -> a + at T2714.hs:8:1 + Expected type: c + Actual type: f0 (a -> b) + Expected type: ((a -> b) -> b) -> c -> a + Actual type: ((a -> b) -> b) -> f0 (a -> b) -> f0 b + In the expression: ffmap + In an equation for `f': f = ffmap diff --git a/testsuite/tests/typecheck/should_fail/T2806.hs b/testsuite/tests/typecheck/should_fail/T2806.hs new file mode 100644 index 0000000000..a130d49528 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2806.hs @@ -0,0 +1,14 @@ + +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -Werror #-} + +-- Trac #2806 + +module Foo where + +import GHC.Base + +foo :: Int +foo = 3 + where (I# _x) = 4 + diff --git a/testsuite/tests/typecheck/should_fail/T2806.stderr b/testsuite/tests/typecheck/should_fail/T2806.stderr new file mode 100644 index 0000000000..ebbffb29eb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2806.stderr @@ -0,0 +1,12 @@ + +T2806.hs:13:11: + Warning: Pattern bindings containing unlifted types should use an outermost bang pattern: + (I# _x) = 4 + In an equation for `foo': + foo + = 3 + where + (I# _x) = 4 + +<no location info>: +Failing due to -Werror. diff --git a/testsuite/tests/typecheck/should_fail/T2846b.hs b/testsuite/tests/typecheck/should_fail/T2846b.hs new file mode 100644 index 0000000000..87468df87e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2846b.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE ImpredicativeTypes, FlexibleContexts #-} +module T2846 where + +f :: String +f = show ([1,2,3] :: [Num a => a]) + diff --git a/testsuite/tests/typecheck/should_fail/T2846b.stderr b/testsuite/tests/typecheck/should_fail/T2846b.stderr new file mode 100644 index 0000000000..79527c15b7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2846b.stderr @@ -0,0 +1,7 @@ + +T2846b.hs:5:5: + No instance for (Show (Num a0 => a0)) + arising from a use of `show' + Possible fix: add an instance declaration for (Show (Num a0 => a0)) + In the expression: show ([1, 2, 3] :: [Num a => a]) + In an equation for `f': f = show ([1, 2, 3] :: [Num a => a]) diff --git a/testsuite/tests/typecheck/should_fail/T2994.hs b/testsuite/tests/typecheck/should_fail/T2994.hs new file mode 100644 index 0000000000..cd09745aba --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2994.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +-- Trac #2994 + +module T2994 where + +class MonadReader a b + +newtype Reader' r a = Reader' (r -> a) + +instance MonadReader Int + +instance MonadReader (Reader' r) + +instance MonadReader r r (Reader' r) diff --git a/testsuite/tests/typecheck/should_fail/T2994.stderr b/testsuite/tests/typecheck/should_fail/T2994.stderr new file mode 100644 index 0000000000..7eab543ad4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T2994.stderr @@ -0,0 +1,15 @@ + +T2994.hs:11:10: + `MonadReader Int' is not applied to enough type arguments + Expected kind `*', but `MonadReader Int' has kind `* -> *' + In the instance declaration for `MonadReader Int' + +T2994.hs:13:23: + `Reader' r' is not applied to enough type arguments + The first argument of `MonadReader' should have kind `*', + but `Reader' r' has kind `* -> *' + In the instance declaration for `MonadReader (Reader' r)' + +T2994.hs:15:10: + `MonadReader' is applied to too many type arguments + In the instance declaration for `MonadReader r r (Reader' r)' diff --git a/testsuite/tests/typecheck/should_fail/T3102.hs b/testsuite/tests/typecheck/should_fail/T3102.hs new file mode 100644 index 0000000000..dd5abb25e1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3102.hs @@ -0,0 +1,12 @@ +{-# OPTIONS -XImplicitParams -XRankNTypes #-} + module Bug where + +t :: forall a. ((?p :: Int) => a) -> String +t _ = "Hello" + +f :: (forall a. a -> String) -> Int +f _ = 3 + +result :: Int +result = f t + diff --git a/testsuite/tests/typecheck/should_fail/T3102.stderr b/testsuite/tests/typecheck/should_fail/T3102.stderr new file mode 100644 index 0000000000..cf3483870d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3102.stderr @@ -0,0 +1,9 @@ + +T3102.hs:11:12: + Couldn't match type `a' with `(?p::Int) => a0' + `a' is a rigid type variable bound by + a type expected by the context: a -> String at T3102.hs:11:10 + Expected type: a -> String + Actual type: ((?p::Int) => a0) -> String + In the first argument of `f', namely `t' + In the expression: f t diff --git a/testsuite/tests/typecheck/should_fail/T3155.hs b/testsuite/tests/typecheck/should_fail/T3155.hs new file mode 100644 index 0000000000..3a4c0d2f77 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3155.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE GADTs, TypeOperators #-} +module T3155 where + +-- Test Trac #3155 +-- Gave bad error message in GHC 6.10 + +data Any s where + Any :: s ix -> ix -> Any s + +data AnyR s r where + AnyR :: s ix -> r ix -> AnyR s r + +unR :: (forall ix. r ix -> ix) -> AnyR s r -> Any s +unR f (AnyR ix rix) = Any ix (f rix) diff --git a/testsuite/tests/typecheck/should_fail/T3155.stderr b/testsuite/tests/typecheck/should_fail/T3155.stderr new file mode 100644 index 0000000000..d26bb6dd08 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3155.stderr @@ -0,0 +1,5 @@ + +T3155.hs:13:18: + Illegal symbol '.' in type + Perhaps you intended -XRankNTypes or similar flag + to enable explicit-forall syntax: forall <tvs>. <type> diff --git a/testsuite/tests/typecheck/should_fail/T3176.hs b/testsuite/tests/typecheck/should_fail/T3176.hs new file mode 100644 index 0000000000..0235ad712f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3176.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- Trac #3176 + +module Foo where + +data ES = forall a. Show a => ES {unES:: a} + +smallPrintES f t = show $ unES $ f t diff --git a/testsuite/tests/typecheck/should_fail/T3176.stderr b/testsuite/tests/typecheck/should_fail/T3176.stderr new file mode 100644 index 0000000000..393880367d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3176.stderr @@ -0,0 +1,7 @@ + +T3176.hs:9:27: + Cannot use record selector `unES' as a function due to escaped type variables + Probable fix: use pattern-matching syntax instead + In the expression: unES + In the second argument of `($)', namely `unES $ f t' + In the expression: show $ unES $ f t diff --git a/testsuite/tests/typecheck/should_fail/T3323.hs b/testsuite/tests/typecheck/should_fail/T3323.hs new file mode 100644 index 0000000000..22ed520806 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3323.hs @@ -0,0 +1,18 @@ +-- Trac #3323 +module T3323 where + +import GHC.IO.Handle.Types +import GHC.IO.Handle.Internals + +-- The point here is that Handle__ is an existential type, +-- so the haDevice field can't be updated. +-- +-- The bug was that, haDevice is a "naughty" selector, we +-- couldn't find its type constructor. +-- +-- This only happened when you go via an interface file, which is why +-- this test imports an existential. To make the test more +-- standalone, you'd need to make it a two-module test + +f :: Handle__ -> Handle__ +f h = h {haDevice=undefined} diff --git a/testsuite/tests/typecheck/should_fail/T3323.stderr b/testsuite/tests/typecheck/should_fail/T3323.stderr new file mode 100644 index 0000000000..d7c4c26681 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3323.stderr @@ -0,0 +1,5 @@ + +T3323.hs:18:7: + Record update for insufficiently polymorphic field: haDevice :: dev + In the expression: h {haDevice = undefined} + In an equation for `f': f h = h {haDevice = undefined} diff --git a/testsuite/tests/typecheck/should_fail/T3406.hs b/testsuite/tests/typecheck/should_fail/T3406.hs new file mode 100644 index 0000000000..3337f3b135 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3406.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE ScopedTypeVariables #-}
+
+-- Trac #3406
+-- A pattern signature that discards the bound variables
+
+module T3406 where
+
+type ItemColID a b = Int -- Discards a,b
+
+get :: ItemColID a b -> a -> ItemColID a b
+get (x :: ItemColID a b) = x :: ItemColID a b
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/T3406.stderr b/testsuite/tests/typecheck/should_fail/T3406.stderr new file mode 100644 index 0000000000..ceba706f87 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3406.stderr @@ -0,0 +1,10 @@ + +T3406.hs:11:6: + The type variables `a, b' + should be bound by the pattern signature `ItemColID a b' + but are actually discarded by a type synonym + To fix this, expand the type synonym + [Note: I hope to lift this restriction in due course] + In the pattern: x :: ItemColID a b + In an equation for `get': + get (x :: ItemColID a b) = x :: ItemColID a b diff --git a/testsuite/tests/typecheck/should_fail/T3468.hs b/testsuite/tests/typecheck/should_fail/T3468.hs new file mode 100644 index 0000000000..ac9aef557a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3468.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module T3468 where + +import {-# SOURCE #-} T3468 + +data Tool d = forall a r . F a + diff --git a/testsuite/tests/typecheck/should_fail/T3468.hs-boot b/testsuite/tests/typecheck/should_fail/T3468.hs-boot new file mode 100644 index 0000000000..5c7704fab5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3468.hs-boot @@ -0,0 +1,4 @@ +module T3468 where + +data Tool + diff --git a/testsuite/tests/typecheck/should_fail/T3468.stderr b/testsuite/tests/typecheck/should_fail/T3468.stderr new file mode 100644 index 0000000000..020d10457a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3468.stderr @@ -0,0 +1,11 @@ + +T3468.hs-boot:3:6: + Type constructor `Tool' has conflicting definitions in the module and its hs-boot file + Main module: data Tool d + RecFlag Recursive + = F :: forall d a r. a -> Tool d Stricts: _ + FamilyInstance: none + Boot file: data Tool + RecFlag NonRecursive + {- abstract -} + FamilyInstance: none diff --git a/testsuite/tests/typecheck/should_fail/T3540.hs b/testsuite/tests/typecheck/should_fail/T3540.hs new file mode 100644 index 0000000000..364193ceb5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3540.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE ImplicitParams, TypeFamilies #-} +module T3540 where + +thing :: (a~Int) +thing = undefined + +thing1 :: Int -> (a~Int) +thing1 = undefined + +thing2 :: (a~Int) -> Int +thing2 = undefined + +thing3 :: (?dude :: Int) -> Int +thing3 = undefined + +thing4:: (Eq a) -> Int +thing4 = undefined
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/T3540.stderr b/testsuite/tests/typecheck/should_fail/T3540.stderr new file mode 100644 index 0000000000..8708dffa5d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3540.stderr @@ -0,0 +1,25 @@ + +T3540.hs:4:12: + Predicate used as a type: a ~ Int + In the type signature for `thing': + thing :: a ~ Int + +T3540.hs:7:20: + Predicate used as a type: a ~ Int + In the type signature for `thing1': + thing1 :: Int -> (a ~ Int) + +T3540.hs:10:13: + Predicate used as a type: a ~ Int + In the type signature for `thing2': + thing2 :: (a ~ Int) -> Int + +T3540.hs:13:12: + Predicate used as a type: ?dude :: Int + In the type signature for `thing3': + thing3 :: (?dude :: Int) -> Int + +T3540.hs:16:11: + Class `Eq' used as a type + In the type signature for `thing4': + thing4 :: (Eq a) -> Int diff --git a/testsuite/tests/typecheck/should_fail/T3613.hs b/testsuite/tests/typecheck/should_fail/T3613.hs new file mode 100644 index 0000000000..9969d63707 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3613.hs @@ -0,0 +1,19 @@ +-- c.f Trac #3613
+
+module T3613 where
+
+import Control.Monad
+
+foo :: Maybe ()
+foo = return ()
+
+bar :: IO ()
+bar = return ()
+
+fun1 = let fooThen m = foo>> m
+ in fooThen (bar>> undefined)
+
+fun2 = let fooThen m = foo>> m
+ in fooThen (do {bar; undefined})
+
+
diff --git a/testsuite/tests/typecheck/should_fail/T3613.stderr b/testsuite/tests/typecheck/should_fail/T3613.stderr new file mode 100644 index 0000000000..feb46416df --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3613.stderr @@ -0,0 +1,17 @@ + +T3613.hs:14:20: + Couldn't match expected type `Maybe a0' with actual type `IO ()' + In the first argument of `(>>)', namely `bar' + In the first argument of `fooThen', namely `(bar >> undefined)' + In the expression: fooThen (bar >> undefined) + +T3613.hs:17:24: + Couldn't match expected type `Maybe a0' with actual type `IO ()' + In a stmt of a 'do' block: bar + In the first argument of `fooThen', namely + `(do { bar; + undefined })' + In the expression: + fooThen + (do { bar; + undefined }) diff --git a/testsuite/tests/typecheck/should_fail/T3950.hs b/testsuite/tests/typecheck/should_fail/T3950.hs new file mode 100644 index 0000000000..127a82b04b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3950.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE GADTs #-}
+
+module T3950 where
+
+-- Id :: (* -> * -> *) -> * -> * -> *
+data Id p x y = Id (p x y)
+
+-- Sealed :: (* -> *) -> *
+data Sealed p where
+ Sealed :: p x -> Sealed p
+
+-- w :: (* -> * -> *) -> *
+-- Id p :: * -> * -> *
+rp :: Bool -> Maybe (w (Id p))
+rp _ = Just rp'
+ where rp' :: Sealed (Id p x)
+ rp' = undefined
diff --git a/testsuite/tests/typecheck/should_fail/T3950.stderr b/testsuite/tests/typecheck/should_fail/T3950.stderr new file mode 100644 index 0000000000..1c326ad43e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3950.stderr @@ -0,0 +1,7 @@ + +T3950.hs:15:13: + Couldn't match expected type `Id p' with actual type `Id p x0' + Expected type: w (Id p) + Actual type: Sealed (Id p x0) + In the first argument of `Just', namely `rp'' + In the expression: Just rp' diff --git a/testsuite/tests/typecheck/should_fail/T3966.hs b/testsuite/tests/typecheck/should_fail/T3966.hs new file mode 100644 index 0000000000..7b1184c710 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3966.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -Werror -O #-} +-- Add -O so the UNPACK has some effect + +module T3966 where + +data Foo a b = Foo {-# UNPACK #-} !(a -> b) diff --git a/testsuite/tests/typecheck/should_fail/T3966.stderr b/testsuite/tests/typecheck/should_fail/T3966.stderr new file mode 100644 index 0000000000..b24087ff8b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T3966.stderr @@ -0,0 +1,9 @@ + +T3966.hs:6:16: + Warning: Ignoring unusable UNPACK pragma on the + first argument of `Foo' + In the definition of data constructor `Foo' + In the data type declaration for `Foo' + +<no location info>: +Failing due to -Werror. diff --git a/testsuite/tests/typecheck/should_fail/T4875.hs b/testsuite/tests/typecheck/should_fail/T4875.hs new file mode 100644 index 0000000000..832bb1c8f5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T4875.hs @@ -0,0 +1,28 @@ + {-# OPTIONS -XMultiParamTypeClasses -XFunctionalDependencies -XFlexibleInstances #-}
+module HaskellBug where
+
+data Relation c -- The basic Relation
+ = Rel { relnm :: String -- The name of the relation
+ , relsrc :: c -- Source concept
+ , reltrg :: c -- ^Target concept
+ }
+ deriving Eq
+
+-- This declaration is ok; should not get an error here
+class (Eq concept)=> Association rel concept | rel -> concept where
+ source, target :: rel -> concept
+ -- e.g. Declaration Concept -> Concept
+ sign :: rel -> (concept,concept)
+ sign x = (source x,target x)
+ homogeneous :: rel -> Bool
+ homogeneous s = source s == target s
+
+instance (Eq c)=>Association (Relation c) c where
+ source = relsrc
+ target = reltrg
+
+-- This declaration has a kind error
+-- The error should be reported here
+class (Eq c, Association r c) => Morphic r c where
+ multiplicities :: r c -> [c]
+ multiplicities _ = []
diff --git a/testsuite/tests/typecheck/should_fail/T4875.stderr b/testsuite/tests/typecheck/should_fail/T4875.stderr new file mode 100644 index 0000000000..24c570e73b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T4875.stderr @@ -0,0 +1,5 @@ +
+T4875.hs:27:24:
+ `r' is applied to too many type arguments
+ In the type `r c -> [c]'
+ In the class declaration for `Morphic'
diff --git a/testsuite/tests/typecheck/should_fail/T5084.hs b/testsuite/tests/typecheck/should_fail/T5084.hs new file mode 100644 index 0000000000..0ae39fd71c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5084.hs @@ -0,0 +1,12 @@ +module T5084 where + +-- Superclass method pragma test (fail) +class Foo a where + bar :: a -> a + {-# INLINE bar #-} + +-- Instance test (ok) +instance Foo Int where + bar = (+1) + {-# INLINE bar #-} + diff --git a/testsuite/tests/typecheck/should_fail/T5084.stderr b/testsuite/tests/typecheck/should_fail/T5084.stderr new file mode 100644 index 0000000000..eba9426342 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5084.stderr @@ -0,0 +1,3 @@ + +T5084.hs:6:5: + The INLINE pragma for default method `bar' lacks an accompanying binding diff --git a/testsuite/tests/typecheck/should_fail/T5236.hs b/testsuite/tests/typecheck/should_fail/T5236.hs new file mode 100644 index 0000000000..07b31c3218 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5236.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleContexts #-} + +module Main where + +data A +data B + +class Id a b | a -> b, b -> a + +instance Id A A +instance Id B B + +loop :: Id A B => Bool +loop = True + +f :: Bool +f = loop + + +main :: IO () +main = return ()
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/T5236.stderr b/testsuite/tests/typecheck/should_fail/T5236.stderr new file mode 100644 index 0000000000..8ec3544f6a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5236.stderr @@ -0,0 +1,20 @@ +
+T5236.hs:17:5:
+ Couldn't match type `B' with `A'
+ When using functional dependencies to combine
+ Id B B,
+ arising from the dependency `b -> a'
+ in the instance declaration at T5236.hs:11:10
+ Id A B, arising from a use of `loop' at T5236.hs:17:5-8
+ In the expression: loop
+ In an equation for `f': f = loop
+
+T5236.hs:17:5:
+ Couldn't match type `A' with `B'
+ When using functional dependencies to combine
+ Id A A,
+ arising from the dependency `a -> b'
+ in the instance declaration at T5236.hs:10:10
+ Id A B, arising from a use of `loop' at T5236.hs:17:5-8
+ In the expression: loop
+ In an equation for `f': f = loop
diff --git a/testsuite/tests/typecheck/should_fail/T5246.hs b/testsuite/tests/typecheck/should_fail/T5246.hs new file mode 100644 index 0000000000..c7b41c0492 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5246.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE ImplicitParams #-}
+
+-- Produced a duplicated error message in 7.0
+
+module T5246 where
+
+foo :: (?x :: Int) => a
+foo = undefined
+
+bar = let ?x = "hello"
+ in foo
diff --git a/testsuite/tests/typecheck/should_fail/T5246.stderr b/testsuite/tests/typecheck/should_fail/T5246.stderr new file mode 100644 index 0000000000..3886cdef07 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5246.stderr @@ -0,0 +1,6 @@ +
+T5246.hs:11:10:
+ Couldn't match type `Int' with `[Char]'
+ In the expression: foo
+ In the expression: let ?x = "hello" in foo
+ In an equation for `bar': bar = let ?x = "hello" in foo
diff --git a/testsuite/tests/typecheck/should_fail/T5300.hs b/testsuite/tests/typecheck/should_fail/T5300.hs new file mode 100644 index 0000000000..d052d84659 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5300.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE FunctionalDependencies, MultiParamTypeClasses #-} +module T5300 where + +import Control.Monad.State (StateT) + +class C1 a b c | a -> b +class C2 a b c + +data T b = T + +f1 :: (Monad m, C1 a b c) => a -> StateT (T b) m a +f1 f = undefined + +f2 :: (Monad m, C1 a1 b1 c1, C2 a2 b2 c2) => a1 -> StateT (T b2) m a2 +f2 fm = f1 fm >>= return . undefined diff --git a/testsuite/tests/typecheck/should_fail/T5300.stderr b/testsuite/tests/typecheck/should_fail/T5300.stderr new file mode 100644 index 0000000000..bc3bc066b5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T5300.stderr @@ -0,0 +1,8 @@ + +T5300.hs:15:9: + Ambiguous type variable `c0' in the constraint: + (C1 a1 b2 c0) arising from a use of `f1' + Probable fix: add a type signature that fixes these type variable(s) + In the first argument of `(>>=)', namely `f1 fm' + In the expression: f1 fm >>= return . undefined + In an equation for `f2': f2 fm = f1 fm >>= return . undefined diff --git a/testsuite/tests/typecheck/should_fail/Tcfail186_Help.hs b/testsuite/tests/typecheck/should_fail/Tcfail186_Help.hs new file mode 100644 index 0000000000..bdf67f4747 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/Tcfail186_Help.hs @@ -0,0 +1,5 @@ +module Tcfail186_Help where + +type PhantomSyn a = Int + +f = (\_ -> 2) :: PhantomSyn a -> Int diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T new file mode 100644 index 0000000000..5ea05ef478 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -0,0 +1,245 @@ + +test('tcfail001', normal, compile_fail, ['']) +test('tcfail002', normal, compile_fail, ['']) +test('tcfail003', normal, compile_fail, ['']) +test('tcfail004', normal, compile_fail, ['']) +test('tcfail005', normal, compile_fail, ['']) +test('tcfail006', normal, compile_fail, ['']) +test('tcfail007', normal, compile_fail, ['']) +test('tcfail008', normal, compile_fail, ['']) +test('tcfail009', normal, compile_fail, ['']) +test('tcfail010', normal, compile_fail, ['']) +test('tcfail011', normal, compile_fail, ['']) +test('tcfail012', normal, compile_fail, ['']) +test('tcfail013', normal, compile_fail, ['']) +test('tcfail014', normal, compile_fail, ['']) +test('tcfail015', normal, compile_fail, ['']) +test('tcfail016', normal, compile_fail, ['']) +test('tcfail017', normal, compile_fail, ['']) +test('tcfail018', normal, compile_fail, ['']) +test('tcfail019', normal, compile_fail, ['']) +test('tcfail020', normal, compile_fail, ['']) +test('tcfail021', normal, compile_fail, ['']) +test('tcfail023', normal, compile_fail, ['']) +test('tcfail027', normal, compile_fail, ['']) +test('tcfail028', normal, compile_fail, ['']) +test('tcfail029', normal, compile_fail, ['']) +test('tcfail030', if_compiler_type('hugs', expect_fail), compile_fail, ['']) +test('tcfail031', normal, compile_fail, ['']) +test('tcfail032', normal, compile_fail, ['']) +test('tcfail033', normal, compile_fail, ['']) +test('tcfail034', normal, compile_fail, ['']) +test('tcfail035', normal, compile_fail, ['']) +test('tcfail036', normal, compile_fail, ['']) +test('tcfail037', normal, compile_fail, ['']) +test('tcfail038', normal, compile_fail, ['']) +test('tcfail040', normal, compile_fail, ['']) +test('tcfail042', normal, compile_fail, ['']) +test('tcfail043', normal, compile_fail, ['']) +test('tcfail044', normal, compile_fail, ['']) +test('tcfail046', normal, compile_fail, ['']) +test('tcfail047', normal, compile_fail, ['']) +test('tcfail048', normal, compile_fail, ['']) +test('tcfail049', normal, compile_fail, ['']) +test('tcfail050', normal, compile_fail, ['']) +test('tcfail051', normal, compile_fail, ['']) +test('tcfail052', normal, compile_fail, ['']) +test('tcfail053', normal, compile_fail, ['']) +test('tcfail054', normal, compile_fail, ['']) +test('tcfail055', normal, compile_fail, ['']) +test('tcfail056', normal, compile_fail, ['']) +test('tcfail057', normal, compile_fail, ['']) +test('tcfail058', normal, compile_fail, ['']) +test('tcfail061', normal, compile_fail, ['']) +test('tcfail062', normal, compile_fail, ['']) +test('tcfail063', normal, compile_fail, ['']) +test('tcfail065', normal, compile_fail, ['']) +test('tcfail067', normal, compile_fail, ['']) +test('tcfail068', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail069', normal, compile_fail, ['']) +test('tcfail070', normal, compile_fail, ['']) +test('tcfail071', normal, compile, ['']) +test('tcfail072', normal, compile_fail, ['']) +test('tcfail073', normal, compile_fail, ['']) +test('tcfail075', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail076', normal, compile_fail, ['']) +test('tcfail077', normal, compile_fail, ['']) +test('tcfail078', normal, compile_fail, ['']) +test('tcfail079', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail080', if_compiler_type('ghc', expect_fail), compile_fail, ['']) +test('tcfail082', normal, compile_fail, ['']) +test('tcfail083', normal, compile_fail, ['']) +test('tcfail084', normal, compile_fail, ['']) +test('tcfail085', normal, compile_fail, ['']) +test('tcfail086', normal, compile_fail, ['']) +test('tcfail087', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail088', normal, compile_fail, ['']) +test('tcfail089', normal, compile_fail, ['']) +test('tcfail090', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail091', normal, compile_fail, ['']) +test('tcfail092', normal, compile_fail, ['']) +test('tcfail093', normal, compile, ['']) +test('tcfail094', normal, compile_fail, ['']) +test('tcfail095', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail096', normal, compile_fail, ['']) +test('tcfail097', normal, compile_fail, ['']) +test('tcfail098', normal, compile_fail, ['']) +test('tcfail099', normal, compile_fail, ['']) +test('tcfail100', normal, compile_fail, ['']) +test('tcfail101', normal, compile_fail, ['']) +test('tcfail102', normal, compile_fail, ['']) +test('tcfail103', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail104', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail105', normal, compile, ['']) +test('tcfail106', normal, compile_fail, ['']) +test('tcfail107', normal, compile_fail, ['']) +test('tcfail108', normal, compile_fail, ['']) +test('tcfail109', normal, compile_fail, ['']) +test('tcfail110', normal, compile_fail, ['']) +test('tcfail112', normal, compile_fail, ['']) +test('tcfail113', normal, compile_fail, ['']) +test('tcfail114', normal, compile_fail, ['']) +test('tcfail115', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail116', normal, compile_fail, ['']) +test('tcfail117', normal, compile_fail, ['']) +test('tcfail118', normal, compile_fail, ['']) +test('tcfail119', normal, compile_fail, ['']) +test('tcfail120', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail121', normal, compile_fail, ['']) +test('tcfail122', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail123', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail124', only_compiler_types(['ghc']), compile, ['']) +test('tcfail125', normal, compile_fail, ['']) +test('tcfail126', reqlib('mtl'), compile, ['']) +test('tcfail127', normal, compile_fail, ['']) +test('tcfail128', normal, compile_fail, ['']) +test('tcfail129', normal, compile_fail, ['']) +test('tcfail130', normal, compile_fail, ['']) +test('tcfail131', normal, compile_fail, ['']) +test('tcfail132', normal, compile_fail, ['']) +test('tcfail133', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail134', normal, compile_fail, ['']) +test('tcfail135', normal, compile_fail, ['']) +test('tcfail136', normal, compile_fail, ['']) +test('tcfail137', normal, compile_fail, ['']) + +test('tcfail138', normal, compile, ['']) +# Now fails; see notes in file + +test('tcfail139', normal, compile_fail, ['']) +test('tcfail140', normal, compile_fail, ['']) +test('tcfail141', only_compiler_types(['ghc']), compile_fail, ['']) +test('tcfail142', normal, compile_fail, ['']) +test('tcfail143', normal, compile_fail, ['']) +test('tcfail144', normal, compile, ['']) +test('tcfail145', normal, compile, ['']) +test('tcfail146', normal, compile_fail, ['']) +test('tcfail147', normal, compile_fail, ['']) +test('tcfail148', normal, compile_fail, ['']) +test('tcfail149', normal, compile_and_run, ['']) +test('tcfail150', normal, compile, ['']) +test('tcfail151', normal, compile_fail, ['']) +test('tcfail152', normal, compile_fail, ['']) +test('tcfail153', normal, compile_fail, ['']) +test('tcfail154', normal, compile_fail, ['']) +test('tcfail155', normal, compile_fail, ['']) +test('tcfail156', normal, compile_fail, ['']) +test('tcfail157', normal, compile_fail, ['']) +test('tcfail158', normal, compile_fail, ['']) +test('tcfail159', normal, compile_fail, ['']) +test('tcfail160', normal, compile_fail, ['']) +test('tcfail161', normal, compile_fail, ['']) +test('tcfail162', normal, compile_fail, ['']) +test('tcfail164', normal, compile_fail, ['']) +test('tcfail165', normal, compile_fail, ['']) +test('tcfail166', normal, compile_fail, ['']) +test('tcfail167', normal, compile_fail, ['']) +test('tcfail168', normal, compile_fail, ['']) +test('tcfail169', normal, compile_fail, ['']) +test('tcfail170', normal, compile_fail, ['']) +test('tcfail171', normal, compile_fail, ['']) +test('tcfail172', normal, compile, ['']) +test('tcfail173', normal, compile_fail, ['']) +test('tcfail174', normal, compile_fail, ['']) +test('tcfail175', normal, compile_fail, ['']) +test('tcfail176', normal, compile_fail, ['']) +test('tcfail177', normal, compile_fail, ['']) +test('tcfail178', normal, compile_fail, ['']) +test('tcfail179', normal, compile_fail, ['']) +test('tcfail180', normal, compile_fail, ['']) +test('tcfail181', normal, compile_fail, ['']) +test('tcfail182', normal, compile_fail, ['']) +test('tcfail183', normal, compile_fail, ['']) +test('tcfail184', normal, compile_fail, ['']) +test('tcfail185', normal, compile_fail, ['']) +test('tcfail186', + extra_clean(['Tcfail186_Help.hi', 'Tcfail186_Help.o']), + multimod_compile_fail, ['tcfail186', '-v0']) +test('tcfail187', normal, compile_fail, ['']) + +test('tcfail188', normal, compile, ['']) + +test('tcfail189', normal, compile_fail, ['']) +test('tcfail190', normal, compile_fail, ['']) +test('tcfail191', normal, compile_fail, ['']) +test('tcfail192', normal, compile_fail, ['']) +test('tcfail193', normal, compile_fail, ['']) +test('tcfail194', normal, compile_fail, ['']) +test('tcfail195', normal, compile_fail, ['']) +test('tcfail196', normal, compile_fail, ['']) +test('tcfail197', normal, compile_fail, ['']) +test('tcfail198', normal, compile_fail, ['']) +test('tcfail199', normal, compile_fail, ['']) +test('tcfail200', normal, compile_fail, ['']) +test('tcfail201', normal, compile_fail, ['']) +test('tcfail202', normal, compile_fail, ['']) +test('tcfail203', normal, compile, ['']) +test('tcfail203a', normal, compile_fail, ['']) +test('tcfail204', normal, compile_fail, ['']) +test('tcfail206', normal, compile_fail, ['']) + +test('T1595', normal, compile_fail, ['']) +test('T1899', normal, compile_fail, ['']) +test('T2126', normal, compile_fail, ['']) +test('T2307', normal, compile_fail, ['']) +test('T2414', normal, compile_fail, ['']) +test('T2538', normal, compile_fail, ['']) +test('T2688', normal, compile_fail, ['']) +test('T2714', normal, compile_fail, ['']) +test('T2994', normal, compile_fail, ['']) +test('T3155', normal, compile_fail, ['']) +test('T3176', normal, compile_fail, ['']) +test('T1633', normal, compile_fail, ['']) +test('T2806', normal, compile_fail, ['']) +test('T3323', normal, compile_fail, ['']) +test('T3406', normal, compile_fail, ['']) +test('T3540', normal, compile_fail, ['']) +test('T3102', normal, compile_fail, ['']) +test('T3613', normal, compile_fail, ['']) +test('fd-loop', normal, compile_fail, ['']) +test('T3950', normal, compile_fail, ['']) +test('T3966', normal, compile_fail, ['']) +test('IPFail', normal, compile_fail, ['']) + +test('T3468', extra_clean(['T3468.hi-boot']), + multimod_compile_fail, ['T3468', '-v0']) +test('T2846b', normal, compile_fail, ['']) +test('FrozenErrorTests', normal, compile_fail, ['']) +test('SCLoop', normal, compile_fail, ['']) +test('T4875', normal, compile_fail, ['']) +test('mc19', normal, compile_fail, ['']) +test('mc20', normal, compile_fail, ['']) +test('mc21', normal, compile_fail, ['']) +test('mc22', normal, compile_fail, ['']) +test('mc23', normal, compile_fail, ['']) +test('mc24', normal, compile_fail, ['']) +test('mc25', normal, compile_fail, ['']) +test('tcfail207', normal, compile_fail, ['']) +test('T5084', normal, compile_fail, ['']) +test('tcfail208', normal, compile_fail, ['']) + +test('FailDueToGivenOverlapping', normal, compile_fail, ['']) +test('LongWayOverlapping', normal, compile_fail, ['']) +test('T5236',normal,compile_fail,['']) +test('T5246',normal,compile_fail,['']) +test('T5300',normal,compile_fail,['']) diff --git a/testsuite/tests/typecheck/should_fail/fd-loop.hs b/testsuite/tests/typecheck/should_fail/fd-loop.hs new file mode 100644 index 0000000000..8b9a22926e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/fd-loop.hs @@ -0,0 +1,32 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
+
+-- Here's a nice example of a fundep loop, correctly
+-- rejected by the undecidable-instance check.
+-- See comments below.
+
+module FDLoop where
+
+class C a b | a -> b where f :: a -> b
+newtype T a = T a
+
+instance (C a b, Eq b) => Eq (T a) where (==) = undefined
+
+g x = (undefined :: d -> d -> d -> ()) (T x) (f x) (undefined :: Eq e => e)
+
+{- Analysis
+
+ f :: C a b => a -> b
+ x :: a
+ b ~ T a
+ need: C a b
+ b ~ e
+ need: Eq e
+
+Hence need (C a (T a), Eq (T a))
+Apply instance for Eq
+ = (C a (T a), C a g, Eq g)
+Apply functional dependency: g ~ T a
+ = (C a (T a), C a (T a), Eq (T a))
+And now we are back where we started
+-}
+
diff --git a/testsuite/tests/typecheck/should_fail/fd-loop.stderr b/testsuite/tests/typecheck/should_fail/fd-loop.stderr new file mode 100644 index 0000000000..9f93b6d9bc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/fd-loop.stderr @@ -0,0 +1,12 @@ + +fd-loop.hs:12:10: + Variable occurs more often in a constraint than in the instance head + in the constraint: C a b + (Use -XUndecidableInstances to permit this) + In the instance declaration for `Eq (T a)' + +fd-loop.hs:12:10: + Variable occurs more often in a constraint than in the instance head + in the constraint: Eq b + (Use -XUndecidableInstances to permit this) + In the instance declaration for `Eq (T a)' diff --git a/testsuite/tests/typecheck/should_fail/mc19.hs b/testsuite/tests/typecheck/should_fail/mc19.hs new file mode 100644 index 0000000000..f5cc693b9a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc19.hs @@ -0,0 +1,11 @@ +-- Checks that the correct type is used checking the using clause of the transform + +{-# LANGUAGE MonadComprehensions, TransformListComp #-} + +module ShouldFail where + +import Data.List(inits) + +z :: [Int] +z = [x | x <- [3, 2, 1], then inits] + diff --git a/testsuite/tests/typecheck/should_fail/mc19.stderr b/testsuite/tests/typecheck/should_fail/mc19.stderr new file mode 100644 index 0000000000..c7bca0afd4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc19.stderr @@ -0,0 +1,9 @@ + +mc19.hs:10:31: + Couldn't match type `a' with `[a]' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [a] at mc19.hs:10:26 + Expected type: [a] -> [a] + Actual type: [a] -> [[a]] + In the expression: inits + In a stmt of a monad comprehension: then inits diff --git a/testsuite/tests/typecheck/should_fail/mc20.hs b/testsuite/tests/typecheck/should_fail/mc20.hs new file mode 100644 index 0000000000..4dd0fe2fe5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc20.hs @@ -0,0 +1,13 @@ + +-- Checks that the ordering constraint on the implicit groupWith is respected + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where + +data Unorderable = Gnorf | Pinky | Brain + +foo = [ () + | x <- [Gnorf, Brain] + , then group by x + ] diff --git a/testsuite/tests/typecheck/should_fail/mc20.stderr b/testsuite/tests/typecheck/should_fail/mc20.stderr new file mode 100644 index 0000000000..1214b6ac17 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc20.stderr @@ -0,0 +1,8 @@ + +mc20.hs:12:9: + No instance for (Ord Unorderable) + arising from a use of `Control.Monad.Group.mgroupWith' + Possible fix: add an instance declaration for (Ord Unorderable) + In the expression: Control.Monad.Group.mgroupWith + In a stmt of a monad comprehension: then group by x + In the expression: [() | x <- [Gnorf, Brain], then group by x] diff --git a/testsuite/tests/typecheck/should_fail/mc21.hs b/testsuite/tests/typecheck/should_fail/mc21.hs new file mode 100644 index 0000000000..601403a6bd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc21.hs @@ -0,0 +1,13 @@ +-- Checks that the correct type is used checking the using clause of the group + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where +import GHC.Exts( the ) + +data Unorderable = Gnorf | Pinky | Brain + +foo = [ length x + | x <- [Gnorf, Brain] + , then group using take 5 + ] diff --git a/testsuite/tests/typecheck/should_fail/mc21.stderr b/testsuite/tests/typecheck/should_fail/mc21.stderr new file mode 100644 index 0000000000..95c077cb25 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc21.stderr @@ -0,0 +1,9 @@ + +mc21.hs:12:26: + Couldn't match type `a' with `[a]' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [[a]] at mc21.hs:12:9 + Expected type: [a] -> [[a]] + Actual type: [a] -> [a] + In the return type of a call of `take' + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/mc22.hs b/testsuite/tests/typecheck/should_fail/mc22.hs new file mode 100644 index 0000000000..dd8d44e6b7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc22.hs @@ -0,0 +1,11 @@ +-- Checks that the types of the old binder and the binder +-- implicitly introduced by grouping are linked + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where + +foo = [ x + 1 + | x <- ["Hello", "World"] + , then group using take 5 + ] diff --git a/testsuite/tests/typecheck/should_fail/mc22.stderr b/testsuite/tests/typecheck/should_fail/mc22.stderr new file mode 100644 index 0000000000..96294ae693 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc22.stderr @@ -0,0 +1,9 @@ + +mc22.hs:10:26: + Couldn't match type `a' with `t0 a' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [t0 a] at mc22.hs:10:9 + Expected type: [a] -> [t0 a] + Actual type: [a] -> [a] + In the return type of a call of `take' + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/mc23.hs b/testsuite/tests/typecheck/should_fail/mc23.hs new file mode 100644 index 0000000000..ab6f3468a4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc23.hs @@ -0,0 +1,10 @@ +-- Checks that using the "by" clause in a transform requires a function parameter + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where + +import Data.List(take) + +z = [x | x <- [1..10], then take 5 by x ] + diff --git a/testsuite/tests/typecheck/should_fail/mc23.stderr b/testsuite/tests/typecheck/should_fail/mc23.stderr new file mode 100644 index 0000000000..ec632f8bdb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc23.stderr @@ -0,0 +1,8 @@ + +mc23.hs:9:29: + Couldn't match expected type `a -> t0' with actual type `[a0]' + Expected type: (a -> t0) -> [a] -> t1 a + Actual type: [a0] -> [a0] + In the return type of a call of `take' + Probable cause: `take' is applied to too many arguments + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/mc24.hs b/testsuite/tests/typecheck/should_fail/mc24.hs new file mode 100644 index 0000000000..9186721229 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc24.hs @@ -0,0 +1,11 @@ +-- Checks that the correct type is used checking the using clause of +-- the group when a by clause is present + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where + +foo = [ length x + | x <- [1..10] + , then group by x using take 2 + ] diff --git a/testsuite/tests/typecheck/should_fail/mc24.stderr b/testsuite/tests/typecheck/should_fail/mc24.stderr new file mode 100644 index 0000000000..bee1592659 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc24.stderr @@ -0,0 +1,8 @@ + +mc24.hs:10:31: + Couldn't match expected type `a -> t0' with actual type `[a0]' + Expected type: (a -> t0) -> [a] -> t1 (t2 a) + Actual type: [a0] -> [a0] + In the return type of a call of `take' + Probable cause: `take' is applied to too many arguments + In the expression: take 2 diff --git a/testsuite/tests/typecheck/should_fail/mc25.hs b/testsuite/tests/typecheck/should_fail/mc25.hs new file mode 100644 index 0000000000..ecbcfde798 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc25.hs @@ -0,0 +1,10 @@ +-- Checks that using the "by" clause in a transform requires a function parameter + +{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-} + +module ShouldFail where + +import Data.List(take) + +z = [x | x <- [1..10], then group by x using take ] + diff --git a/testsuite/tests/typecheck/should_fail/mc25.stderr b/testsuite/tests/typecheck/should_fail/mc25.stderr new file mode 100644 index 0000000000..7016fad147 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/mc25.stderr @@ -0,0 +1,7 @@ + +mc25.hs:9:46: + Couldn't match expected type `a -> t0' with actual type `Int' + Expected type: (a -> t0) -> [a] -> t1 (t2 a) + Actual type: Int -> [a0] -> [a0] + In the expression: take + In a stmt of a monad comprehension: then group by x using take diff --git a/testsuite/tests/typecheck/should_fail/tcfail001.hs b/testsuite/tests/typecheck/should_fail/tcfail001.hs new file mode 100644 index 0000000000..4e3e13072f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail001.hs @@ -0,0 +1,9 @@ +-- !!! This should fail with a type error: the instance method +-- !!! has a function type when it should have the type [a]. +module ShouldFail where + +class A a where + op :: a + +instance (A a, A a) => A [a] where + op [] = [] diff --git a/testsuite/tests/typecheck/should_fail/tcfail001.stderr b/testsuite/tests/typecheck/should_fail/tcfail001.stderr new file mode 100644 index 0000000000..5fadcf6271 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail001.stderr @@ -0,0 +1,5 @@ + +tcfail001.hs:9:2: + The equation(s) for `op' have one argument, + but its type `[a]' has none + In the instance declaration for `A [a]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail001.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail001.stderr-hugs new file mode 100644 index 0000000000..7b82227ee6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail001.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail001.hs":9 - Type error in instance member binding +*** Term : op +*** Type : [b] -> [c] +*** Does not match : [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail002.hs b/testsuite/tests/typecheck/should_fail/tcfail002.hs new file mode 100644 index 0000000000..b1fdd165b4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail002.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +c (x:y) = x +c z = z diff --git a/testsuite/tests/typecheck/should_fail/tcfail002.stderr b/testsuite/tests/typecheck/should_fail/tcfail002.stderr new file mode 100644 index 0000000000..12a77d0cc8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail002.stderr @@ -0,0 +1,5 @@ + +tcfail002.hs:4:7: + Occurs check: cannot construct the infinite type: t0 = [t0] + In the expression: z + In an equation for `c': c z = z diff --git a/testsuite/tests/typecheck/should_fail/tcfail002.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail002.stderr-hugs new file mode 100644 index 0000000000..52a41cd2e3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail002.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail002.hs":4 - Type error in function binding +*** Term : c +*** Type : a -> a +*** Does not match : [a] -> a +*** Because : unification would give infinite type diff --git a/testsuite/tests/typecheck/should_fail/tcfail003.hs b/testsuite/tests/typecheck/should_fail/tcfail003.hs new file mode 100644 index 0000000000..8458014c1b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail003.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(d:e) = [1,'a'] diff --git a/testsuite/tests/typecheck/should_fail/tcfail003.stderr b/testsuite/tests/typecheck/should_fail/tcfail003.stderr new file mode 100644 index 0000000000..62fb6a9812 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail003.stderr @@ -0,0 +1,8 @@ + +tcfail003.hs:3:10: + No instance for (Num Char) + arising from the literal `1' + Possible fix: add an instance declaration for (Num Char) + In the expression: 1 + In the expression: [1, 'a'] + In a pattern binding: (d : e) = [1, 'a'] diff --git a/testsuite/tests/typecheck/should_fail/tcfail003.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail003.stderr-hugs new file mode 100644 index 0000000000..3655bd61a7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail003.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail003.hs":3 - Unresolved top-level overloading +*** Binding : d +*** Outstanding context : Num Char diff --git a/testsuite/tests/typecheck/should_fail/tcfail004.hs b/testsuite/tests/typecheck/should_fail/tcfail004.hs new file mode 100644 index 0000000000..513680bd12 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail004.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(f,g) = (1,2,3) diff --git a/testsuite/tests/typecheck/should_fail/tcfail004.stderr b/testsuite/tests/typecheck/should_fail/tcfail004.stderr new file mode 100644 index 0000000000..5f0408880c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail004.stderr @@ -0,0 +1,6 @@ + +tcfail004.hs:3:9: + Couldn't match expected type `(t0, t1)' + with actual type `(t2, t3, t4)' + In the expression: (1, 2, 3) + In a pattern binding: (f, g) = (1, 2, 3) diff --git a/testsuite/tests/typecheck/should_fail/tcfail004.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail004.stderr-hugs new file mode 100644 index 0000000000..90f8a8105e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail004.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail004.hs":3 - Type error in right hand side +*** Term : (1,2,3) +*** Type : (c,d,e) +*** Does not match : (a,b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail005.hs b/testsuite/tests/typecheck/should_fail/tcfail005.hs new file mode 100644 index 0000000000..ca211e1216 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail005.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(h:i) = (1,'a') diff --git a/testsuite/tests/typecheck/should_fail/tcfail005.stderr b/testsuite/tests/typecheck/should_fail/tcfail005.stderr new file mode 100644 index 0000000000..8a158f5c8d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail005.stderr @@ -0,0 +1,5 @@ + +tcfail005.hs:3:9: + Couldn't match expected type `[t0]' with actual type `(t1, t2)' + In the expression: (1, 'a') + In a pattern binding: (h : i) = (1, 'a') diff --git a/testsuite/tests/typecheck/should_fail/tcfail005.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail005.stderr-hugs new file mode 100644 index 0000000000..e52ab03426 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail005.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail005.hs":3 - Type error in right hand side +*** Term : (1,'a') +*** Type : (b,Char) +*** Does not match : [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail006.hs b/testsuite/tests/typecheck/should_fail/tcfail006.hs new file mode 100644 index 0000000000..37fd1f9c35 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail006.hs @@ -0,0 +1,5 @@ +module ShouldFail where + +(j,k) = case (if True then True else False) of + True -> (True,1) + False -> (1,True) diff --git a/testsuite/tests/typecheck/should_fail/tcfail006.stderr b/testsuite/tests/typecheck/should_fail/tcfail006.stderr new file mode 100644 index 0000000000..b2a3f5b04a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail006.stderr @@ -0,0 +1,8 @@ + +tcfail006.hs:5:20: + No instance for (Num Bool) + arising from the literal `1' + Possible fix: add an instance declaration for (Num Bool) + In the expression: 1 + In the expression: (1, True) + In a case alternative: False -> (1, True) diff --git a/testsuite/tests/typecheck/should_fail/tcfail006.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail006.stderr-hugs new file mode 100644 index 0000000000..617112e3f2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail006.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail006.hs":3 - Unresolved top-level overloading +*** Binding : j +*** Outstanding context : Num Bool diff --git a/testsuite/tests/typecheck/should_fail/tcfail007.hs b/testsuite/tests/typecheck/should_fail/tcfail007.hs new file mode 100644 index 0000000000..ee24983aff --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail007.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +n x | True = x+1 + | False = True diff --git a/testsuite/tests/typecheck/should_fail/tcfail007.stderr b/testsuite/tests/typecheck/should_fail/tcfail007.stderr new file mode 100644 index 0000000000..3545f8644f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail007.stderr @@ -0,0 +1,11 @@ + +tcfail007.hs:3:16: + No instance for (Num Bool) + arising from the literal `1' + Possible fix: add an instance declaration for (Num Bool) + In the second argument of `(+)', namely `1' + In the expression: x + 1 + In an equation for `n': + n x + | True = x + 1 + | False = True diff --git a/testsuite/tests/typecheck/should_fail/tcfail007.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail007.stderr-hugs new file mode 100644 index 0000000000..cd78c91def --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail007.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail007.hs":3 - Instance of Num Bool required for definition of n diff --git a/testsuite/tests/typecheck/should_fail/tcfail008.hs b/testsuite/tests/typecheck/should_fail/tcfail008.hs new file mode 100644 index 0000000000..dbc9d0c911 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail008.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +o = 1:2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail008.stderr b/testsuite/tests/typecheck/should_fail/tcfail008.stderr new file mode 100644 index 0000000000..2d31ee6034 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail008.stderr @@ -0,0 +1,8 @@ + +tcfail008.hs:3:7: + No instance for (Num [a0]) + arising from the literal `2' + Possible fix: add an instance declaration for (Num [a0]) + In the second argument of `(:)', namely `2' + In the expression: 1 : 2 + In an equation for `o': o = 1 : 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail008.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail008.stderr-hugs new file mode 100644 index 0000000000..820654317f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail008.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail008.hs":3 - Unresolved top-level overloading +*** Binding : o +*** Outstanding context : (Num [b], Num b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail009.hs b/testsuite/tests/typecheck/should_fail/tcfail009.hs new file mode 100644 index 0000000000..e8afa0fbf7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail009.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +p = [(1::Int)..(2::Integer)] diff --git a/testsuite/tests/typecheck/should_fail/tcfail009.stderr b/testsuite/tests/typecheck/should_fail/tcfail009.stderr new file mode 100644 index 0000000000..8226c1fbdc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail009.stderr @@ -0,0 +1,6 @@ + +tcfail009.hs:3:17: + Couldn't match expected type `Int' with actual type `Integer' + In the expression: (2 :: Integer) + In the expression: [(1 :: Int) .. (2 :: Integer)] + In an equation for `p': p = [(1 :: Int) .. (2 :: Integer)] diff --git a/testsuite/tests/typecheck/should_fail/tcfail009.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail009.stderr-hugs new file mode 100644 index 0000000000..9b02c99702 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail009.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail009.hs":3 - Type error in application +*** Expression : enumFromTo 1 2 +*** Term : 1 +*** Type : Int +*** Does not match : Integer diff --git a/testsuite/tests/typecheck/should_fail/tcfail010.hs b/testsuite/tests/typecheck/should_fail/tcfail010.hs new file mode 100644 index 0000000000..8b793355da --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail010.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +q = \ (y:z) -> z+2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail010.stderr b/testsuite/tests/typecheck/should_fail/tcfail010.stderr new file mode 100644 index 0000000000..34a52ed1d2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail010.stderr @@ -0,0 +1,8 @@ + +tcfail010.hs:3:18: + No instance for (Num [t0]) + arising from the literal `2' + Possible fix: add an instance declaration for (Num [t0]) + In the second argument of `(+)', namely `2' + In the expression: z + 2 + In the expression: \ (y : z) -> z + 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail010.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail010.stderr-hugs new file mode 100644 index 0000000000..3cc7f66919 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail010.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail010.hs":3 - Unresolved top-level overloading +*** Binding : q +*** Outstanding context : Num [b] diff --git a/testsuite/tests/typecheck/should_fail/tcfail011.hs b/testsuite/tests/typecheck/should_fail/tcfail011.hs new file mode 100644 index 0000000000..89f5c4bcd1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail011.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +z = \y -> x x where x = y diff --git a/testsuite/tests/typecheck/should_fail/tcfail011.stderr b/testsuite/tests/typecheck/should_fail/tcfail011.stderr new file mode 100644 index 0000000000..f41e3a67ce --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail011.stderr @@ -0,0 +1,2 @@ + +tcfail011.hs:3:25: Not in scope: `y' diff --git a/testsuite/tests/typecheck/should_fail/tcfail011.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail011.stderr-hugs new file mode 100644 index 0000000000..d4605dd854 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail011.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail011.hs":3 - Undefined variable "y" diff --git a/testsuite/tests/typecheck/should_fail/tcfail012.hs b/testsuite/tests/typecheck/should_fail/tcfail012.hs new file mode 100644 index 0000000000..67e5fa0256 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail012.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +True = [] diff --git a/testsuite/tests/typecheck/should_fail/tcfail012.stderr b/testsuite/tests/typecheck/should_fail/tcfail012.stderr new file mode 100644 index 0000000000..7fe9b18d47 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail012.stderr @@ -0,0 +1,5 @@ + +tcfail012.hs:3:8: + Couldn't match expected type `Bool' with actual type `[a0]' + In the expression: [] + In a pattern binding: True = [] diff --git a/testsuite/tests/typecheck/should_fail/tcfail012.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail012.stderr-hugs new file mode 100644 index 0000000000..87c9b53fd0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail012.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail012.hs":3 - Type error in right hand side +*** Term : [] +*** Type : [a] +*** Does not match : Bool diff --git a/testsuite/tests/typecheck/should_fail/tcfail013.hs b/testsuite/tests/typecheck/should_fail/tcfail013.hs new file mode 100644 index 0000000000..c9ccc52a64 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail013.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +f [] = 1 +f True = 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail013.stderr b/testsuite/tests/typecheck/should_fail/tcfail013.stderr new file mode 100644 index 0000000000..439a663c5c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail013.stderr @@ -0,0 +1,5 @@ + +tcfail013.hs:4:3: + Couldn't match expected type `[t0]' with actual type `Bool' + In the pattern: True + In an equation for `f': f True = 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail013.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail013.stderr-hugs new file mode 100644 index 0000000000..ed08baca77 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail013.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail013.hs":4 - Type error in function binding +*** Term : f +*** Type : Bool -> b +*** Does not match : [a] -> b diff --git a/testsuite/tests/typecheck/should_fail/tcfail014.hs b/testsuite/tests/typecheck/should_fail/tcfail014.hs new file mode 100644 index 0000000000..7d9169936d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail014.hs @@ -0,0 +1,5 @@ +module ShouldFail where + +f x = g+1 + where g y = h+2 + where h z = z z diff --git a/testsuite/tests/typecheck/should_fail/tcfail014.stderr b/testsuite/tests/typecheck/should_fail/tcfail014.stderr new file mode 100644 index 0000000000..d46bf92db3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail014.stderr @@ -0,0 +1,6 @@ + +tcfail014.hs:5:33: + Occurs check: cannot construct the infinite type: t1 = t1 -> t0 + In the first argument of `z', namely `z' + In the expression: z z + In an equation for `h': h z = z z diff --git a/testsuite/tests/typecheck/should_fail/tcfail014.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail014.stderr-hugs new file mode 100644 index 0000000000..773b9ec586 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail014.stderr-hugs @@ -0,0 +1,6 @@ +ERROR "tcfail014.hs":5 - Type error in application +*** Expression : z z +*** Term : z +*** Type : a -> b +*** Does not match : a +*** Because : unification would give infinite type diff --git a/testsuite/tests/typecheck/should_fail/tcfail015.hs b/testsuite/tests/typecheck/should_fail/tcfail015.hs new file mode 100644 index 0000000000..ae929e3973 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail015.hs @@ -0,0 +1,9 @@ +module ShouldFail where + +data AList a = ANull | ANode a (AList a) + +type IntList = AList Int + +g (ANull) = 2 +g (ANode b (ANode c d)) | b = c+1 + | otherwise = 4 diff --git a/testsuite/tests/typecheck/should_fail/tcfail015.stderr b/testsuite/tests/typecheck/should_fail/tcfail015.stderr new file mode 100644 index 0000000000..52dc7956cd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail015.stderr @@ -0,0 +1,10 @@ + +tcfail015.hs:9:39: + No instance for (Num Bool) + arising from the literal `4' + Possible fix: add an instance declaration for (Num Bool) + In the expression: 4 + In an equation for `g': + g (ANode b (ANode c d)) + | b = c + 1 + | otherwise = 4 diff --git a/testsuite/tests/typecheck/should_fail/tcfail015.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail015.stderr-hugs new file mode 100644 index 0000000000..6884840cdb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail015.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail015.hs":7 - Instance of Num Bool required for definition of g diff --git a/testsuite/tests/typecheck/should_fail/tcfail016.hs b/testsuite/tests/typecheck/should_fail/tcfail016.hs new file mode 100644 index 0000000000..2dfd4a50e0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail016.hs @@ -0,0 +1,9 @@ +module ShouldFail where + +type AnnExpr a = (a,Expr a) + +data Expr a = Var [Char] + | App (AnnExpr a) (AnnExpr a) + +g (Var name) = [name] +g (App e1 e2) = (g e1)++(g e2) diff --git a/testsuite/tests/typecheck/should_fail/tcfail016.stderr b/testsuite/tests/typecheck/should_fail/tcfail016.stderr new file mode 100644 index 0000000000..6420918b37 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail016.stderr @@ -0,0 +1,7 @@ + +tcfail016.hs:9:20: + Couldn't match expected type `Expr t0' + with actual type `AnnExpr t0' + In the first argument of `g', namely `e1' + In the first argument of `(++)', namely `(g e1)' + In the expression: (g e1) ++ (g e2) diff --git a/testsuite/tests/typecheck/should_fail/tcfail016.stderr-ghc-7.0 b/testsuite/tests/typecheck/should_fail/tcfail016.stderr-ghc-7.0 new file mode 100644 index 0000000000..8d2b960eef --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail016.stderr-ghc-7.0 @@ -0,0 +1,8 @@ + +tcfail016.hs:9:20: + Couldn't match expected type `Expr t0' + with actual type `(t0, Expr t0)' + Expected type: Expr t0 + Actual type: AnnExpr t0 + In the first argument of `g', namely `e1' + In the first argument of `(++)', namely `(g e1)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail016.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail016.stderr-hugs new file mode 100644 index 0000000000..cfde47e2fb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail016.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail016.hs":9 - Type error in application +*** Expression : g e2 +*** Term : e2 +*** Type : (b,Expr b) +*** Does not match : Expr a diff --git a/testsuite/tests/typecheck/should_fail/tcfail017.hs b/testsuite/tests/typecheck/should_fail/tcfail017.hs new file mode 100644 index 0000000000..db3215dc19 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail017.hs @@ -0,0 +1,13 @@ + +module ShouldFail where + +class C a where + op1 :: a -> a + +class (C a) => B a where + op2 :: a -> a -> a + +instance (B a) => B [a] where + op2 xs ys = xs + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail017.stderr b/testsuite/tests/typecheck/should_fail/tcfail017.stderr new file mode 100644 index 0000000000..4f09814afa --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail017.stderr @@ -0,0 +1,10 @@ + +tcfail017.hs:10:10: + Could not deduce (C [a]) + arising from the superclasses of an instance declaration + from the context (B a) + bound by the instance declaration at tcfail017.hs:10:10-23 + Possible fix: + add (C [a]) to the context of the instance declaration + or add an instance declaration for (C [a]) + In the instance declaration for `B [a]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail017.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail017.stderr-hugs new file mode 100644 index 0000000000..a52b3c9715 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail017.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail017.hs":10 - Cannot build superclass instance +*** Instance : B [a] +*** Context supplied : B a +*** Required superclass : C [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail018.hs b/testsuite/tests/typecheck/should_fail/tcfail018.hs new file mode 100644 index 0000000000..9d811dcda2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail018.hs @@ -0,0 +1,5 @@ + + +module ShouldFail where + +(a:[]) = 1 diff --git a/testsuite/tests/typecheck/should_fail/tcfail018.stderr b/testsuite/tests/typecheck/should_fail/tcfail018.stderr new file mode 100644 index 0000000000..67ee509537 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail018.stderr @@ -0,0 +1,7 @@ + +tcfail018.hs:5:10: + No instance for (Num [t0]) + arising from the literal `1' + Possible fix: add an instance declaration for (Num [t0]) + In the expression: 1 + In a pattern binding: (a : []) = 1 diff --git a/testsuite/tests/typecheck/should_fail/tcfail018.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail018.stderr-hugs new file mode 100644 index 0000000000..4df764f201 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail018.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail018.hs":5 - Unresolved top-level overloading +*** Binding : a +*** Outstanding context : Num [b] diff --git a/testsuite/tests/typecheck/should_fail/tcfail019.hs b/testsuite/tests/typecheck/should_fail/tcfail019.hs new file mode 100644 index 0000000000..af46532f44 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail019.hs @@ -0,0 +1,20 @@ +module ShouldFail where + +class A a where + p1 :: a -> a + p2 :: a -> a -> a + +class (A b) => B b where + p3 :: b + p4 :: b -> b + +class (A c) => C c where + p5 :: c -> c + p6 :: c -> Int + +class (B d,C d) => D d where + p7 :: d -> d + +instance D [a] where + p7 l = [] + diff --git a/testsuite/tests/typecheck/should_fail/tcfail019.stderr b/testsuite/tests/typecheck/should_fail/tcfail019.stderr new file mode 100644 index 0000000000..0f24d012f6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail019.stderr @@ -0,0 +1,12 @@ + +tcfail019.hs:18:10: + No instance for (B [a]) + arising from the superclasses of an instance declaration + Possible fix: add an instance declaration for (B [a]) + In the instance declaration for `D [a]' + +tcfail019.hs:18:10: + No instance for (C [a]) + arising from the superclasses of an instance declaration + Possible fix: add an instance declaration for (C [a]) + In the instance declaration for `D [a]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail019.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail019.stderr-hugs new file mode 100644 index 0000000000..879bea35de --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail019.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail019.hs":18 - Cannot build superclass instance +*** Instance : D [a] +*** Context supplied : () +*** Required superclass : B [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail020.hs b/testsuite/tests/typecheck/should_fail/tcfail020.hs new file mode 100644 index 0000000000..0d3dc2594a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail020.hs @@ -0,0 +1,16 @@ +module ShouldFail where + +class A a where + p1 :: a -> a + p2 :: a -> a -> a + +class (A b) => B b where + p3 :: b + +instance (A a) => B [a] where + p3 = [] + +data X = XC --, causes stack dump + +--instance B Bool where +-- p3 = True diff --git a/testsuite/tests/typecheck/should_fail/tcfail020.stderr b/testsuite/tests/typecheck/should_fail/tcfail020.stderr new file mode 100644 index 0000000000..3e0df9e42b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail020.stderr @@ -0,0 +1,10 @@ + +tcfail020.hs:10:10: + Could not deduce (A [a]) + arising from the superclasses of an instance declaration + from the context (A a) + bound by the instance declaration at tcfail020.hs:10:10-23 + Possible fix: + add (A [a]) to the context of the instance declaration + or add an instance declaration for (A [a]) + In the instance declaration for `B [a]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail020.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail020.stderr-hugs new file mode 100644 index 0000000000..08d4e497b1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail020.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail020.hs":10 - Cannot build superclass instance +*** Instance : B [a] +*** Context supplied : A a +*** Required superclass : A [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail021.hs b/testsuite/tests/typecheck/should_fail/tcfail021.hs new file mode 100644 index 0000000000..af11b56df9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail021.hs @@ -0,0 +1,8 @@ +-- !!! Illegally giving methods in a pattern binding (for no v good reason...) + +module ShouldFail where + +data Foo = MkFoo Int + +instance Eq Foo where + ((==), (/=)) = (\x -> \y -> True, \x -> \y -> False) diff --git a/testsuite/tests/typecheck/should_fail/tcfail021.stderr b/testsuite/tests/typecheck/should_fail/tcfail021.stderr new file mode 100644 index 0000000000..5a4e8055bc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail021.stderr @@ -0,0 +1,4 @@ + +tcfail021.hs:8:5: + Pattern bindings (except simple variables) not allowed in instance declarations + (==, /=) = (\ x -> \ y -> True, \ x -> \ y -> False) diff --git a/testsuite/tests/typecheck/should_fail/tcfail021.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail021.stderr-hugs new file mode 100644 index 0000000000..948d2e7d6d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail021.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail021.hs":8 - Pattern binding illegal in instance declaration diff --git a/testsuite/tests/typecheck/should_fail/tcfail023.hs b/testsuite/tests/typecheck/should_fail/tcfail023.hs new file mode 100644 index 0000000000..74bcaf3a4b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail023.hs @@ -0,0 +1,16 @@ +module ShouldFail where + +-- !!! Duplicate instances + +data B = C + +class A a where + op :: a -> Bool + +instance A B where + op C = True + +instance A B where + op C = True + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail023.stderr b/testsuite/tests/typecheck/should_fail/tcfail023.stderr new file mode 100644 index 0000000000..96cdb4ebc0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail023.stderr @@ -0,0 +1,5 @@ + +tcfail023.hs:10:10: + Duplicate instance declarations: + instance A B -- Defined at tcfail023.hs:10:10-12 + instance A B -- Defined at tcfail023.hs:13:10-12 diff --git a/testsuite/tests/typecheck/should_fail/tcfail023.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail023.stderr-hugs new file mode 100644 index 0000000000..84b92be57c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail023.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail023.hs":13 - Overlapping instances for class "A" +*** This instance : A B +*** Overlaps with : A B +*** Common instance : A B diff --git a/testsuite/tests/typecheck/should_fail/tcfail025.stderr b/testsuite/tests/typecheck/should_fail/tcfail025.stderr new file mode 100644 index 0000000000..6a0f830cc4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail025.stderr @@ -0,0 +1,8 @@ + +tcfail025.hs:2: + Conflicting exports for local name: A + module Main + module Main + + +Compilation had errors diff --git a/testsuite/tests/typecheck/should_fail/tcfail026.stderr b/testsuite/tests/typecheck/should_fail/tcfail026.stderr new file mode 100644 index 0000000000..23e90f7ae4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail026.stderr @@ -0,0 +1,13 @@ + +tcfail026.hs:2: + Conflicting exports for local name: A + module Main + module Main + +tcfail026.hs:6: + Class type variable ``a'' does not appear in method signature: + op2 :: + `b' -> `b' + + +Compilation had errors diff --git a/testsuite/tests/typecheck/should_fail/tcfail027.hs b/testsuite/tests/typecheck/should_fail/tcfail027.hs new file mode 100644 index 0000000000..e01f6961bd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail027.hs @@ -0,0 +1,8 @@ +-- !!! tests for CycleErr in classes +module TcFail where + +class (B a) => A a where + op1 :: a -> a + +class (A a) => B a where + op2 :: a -> a -> a diff --git a/testsuite/tests/typecheck/should_fail/tcfail027.stderr b/testsuite/tests/typecheck/should_fail/tcfail027.stderr new file mode 100644 index 0000000000..d51c253617 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail027.stderr @@ -0,0 +1,5 @@ +
+tcfail027.hs:4:1:
+ Cycle in class declarations (via superclasses):
+ tcfail027.hs:(4,1)-(5,14): class B a => A a
+ tcfail027.hs:(7,1)-(8,19): class A a => B a
diff --git a/testsuite/tests/typecheck/should_fail/tcfail027.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail027.stderr-hugs new file mode 100644 index 0000000000..fd1b771772 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail027.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail027.hs":7 - Superclass relation for "B" is cyclic diff --git a/testsuite/tests/typecheck/should_fail/tcfail028.hs b/testsuite/tests/typecheck/should_fail/tcfail028.hs new file mode 100644 index 0000000000..5f9b32c07f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail028.hs @@ -0,0 +1,4 @@ +-- !!! tests for ArityErr +module TcFail where + +data A a b = B (A a) diff --git a/testsuite/tests/typecheck/should_fail/tcfail028.stderr b/testsuite/tests/typecheck/should_fail/tcfail028.stderr new file mode 100644 index 0000000000..7ad9ecbb23 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail028.stderr @@ -0,0 +1,7 @@ + +tcfail028.hs:4:17: + `A a' is not applied to enough type arguments + Expected kind `?', but `A a' has kind `k0 -> *' + In the type `A a' + In the definition of data constructor `B' + In the data type declaration for `A' diff --git a/testsuite/tests/typecheck/should_fail/tcfail028.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail028.stderr-hugs new file mode 100644 index 0000000000..a64425da98 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail028.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail028.hs":4 - Illegal type "A a -> A a b" in constructor application diff --git a/testsuite/tests/typecheck/should_fail/tcfail029.hs b/testsuite/tests/typecheck/should_fail/tcfail029.hs new file mode 100644 index 0000000000..14dd2d7e6b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail029.hs @@ -0,0 +1,6 @@ +-- !!! tests for InstOpErr +module ShouldFail where + +data Foo = Bar | Baz + +f x = x > Bar diff --git a/testsuite/tests/typecheck/should_fail/tcfail029.stderr b/testsuite/tests/typecheck/should_fail/tcfail029.stderr new file mode 100644 index 0000000000..cf83c561b9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail029.stderr @@ -0,0 +1,7 @@ + +tcfail029.hs:6:9: + No instance for (Ord Foo) + arising from a use of `>' + Possible fix: add an instance declaration for (Ord Foo) + In the expression: x > Bar + In an equation for `f': f x = x > Bar diff --git a/testsuite/tests/typecheck/should_fail/tcfail029.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail029.stderr-hugs new file mode 100644 index 0000000000..e9a48fd076 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail029.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail029.hs":6 - Instance of Ord Foo required for definition of f diff --git a/testsuite/tests/typecheck/should_fail/tcfail030.hs b/testsuite/tests/typecheck/should_fail/tcfail030.hs new file mode 100644 index 0000000000..163c727518 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail030.hs @@ -0,0 +1,2 @@ +-- !!! empty file + diff --git a/testsuite/tests/typecheck/should_fail/tcfail030.stderr b/testsuite/tests/typecheck/should_fail/tcfail030.stderr new file mode 100644 index 0000000000..cb9d80959d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail030.stderr @@ -0,0 +1,3 @@ + +tcfail030.hs:1:1: + The function `main' is not defined in module `Main' diff --git a/testsuite/tests/typecheck/should_fail/tcfail031.hs b/testsuite/tests/typecheck/should_fail/tcfail031.hs new file mode 100644 index 0000000000..6b9a0de12b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail031.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = if 'a' then 1 else 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail031.stderr b/testsuite/tests/typecheck/should_fail/tcfail031.stderr new file mode 100644 index 0000000000..f7fc14bb1f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail031.stderr @@ -0,0 +1,6 @@ + +tcfail031.hs:3:10: + Couldn't match expected type `Bool' with actual type `Char' + In the expression: 'a' + In the expression: if 'a' then 1 else 2 + In an equation for `f': f x = if 'a' then 1 else 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail031.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail031.stderr-hugs new file mode 100644 index 0000000000..a955d833cb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail031.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail031.hs":3 - Type error in conditional +*** Expression : if 'a' then 1 else 2 +*** Term : 'a' +*** Type : Char +*** Does not match : Bool diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.hs b/testsuite/tests/typecheck/should_fail/tcfail032.hs new file mode 100644 index 0000000000..5950064655 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail032.hs @@ -0,0 +1,16 @@ +{- This test gives the following not-very-wonderful error message. + + "tc_sig.hs", line 3: Type signature does not match the inferred type: + Signature: t76 -> Int + Inferred type: t75 + +It *is* an error, because x does not have the polytype + forall a. Eq a => a -> Int +becuase it is monomorphic, but the error message isn't very illuminating. +-} + +module ShouldFail where + +f x = (x :: (Eq a) => a -> Int) + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.stderr b/testsuite/tests/typecheck/should_fail/tcfail032.stderr new file mode 100644 index 0000000000..8cb4c1b99a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail032.stderr @@ -0,0 +1,14 @@ + +tcfail032.hs:14:8: + Could not deduce (t ~ (a1 -> Int)) + from the context (Eq a) + bound by the inferred type of f :: Eq a => t -> a -> Int + at tcfail032.hs:14:1-31 + or from (Eq a1) + bound by an expression type signature: Eq a1 => a1 -> Int + at tcfail032.hs:14:8-30 + `t' is a rigid type variable bound by + the inferred type of f :: Eq a => t -> a -> Int + at tcfail032.hs:14:1 + In the expression: (x :: Eq a => a -> Int) + In an equation for `f': f x = (x :: Eq a => a -> Int) diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail032.stderr-hugs new file mode 100644 index 0000000000..39879dc120 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail032.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail032.hs":14 - Inferred type is not general enough +*** Expression : x +*** Expected type : Eq a => a -> Int +*** Inferred type : Eq _5 => _5 -> Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail033.hs b/testsuite/tests/typecheck/should_fail/tcfail033.hs new file mode 100644 index 0000000000..fdc0aff8ed --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail033.hs @@ -0,0 +1,4 @@ +-- from Jon Hill +module ShouldFail where + +buglet = [ x | (x,y) <- buglet ] diff --git a/testsuite/tests/typecheck/should_fail/tcfail033.stderr b/testsuite/tests/typecheck/should_fail/tcfail033.stderr new file mode 100644 index 0000000000..826ad4626d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail033.stderr @@ -0,0 +1,6 @@ + +tcfail033.hs:4:12: + Occurs check: cannot construct the infinite type: t0 = (t0, t1) + In the expression: x + In the expression: [x | (x, y) <- buglet] + In an equation for `buglet': buglet = [x | (x, y) <- buglet] diff --git a/testsuite/tests/typecheck/should_fail/tcfail033.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail033.stderr-hugs new file mode 100644 index 0000000000..aed2ee660e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail033.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail033.hs":4 - Type error in function binding +*** Term : buglet +*** Type : [a] +*** Does not match : [(a,b)] +*** Because : unification would give infinite type diff --git a/testsuite/tests/typecheck/should_fail/tcfail034.hs b/testsuite/tests/typecheck/should_fail/tcfail034.hs new file mode 100644 index 0000000000..0bbb75fab8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail034.hs @@ -0,0 +1,39 @@ +{- +From: Jon Hill <hilly@dcs.qmw.ac.uk@jess.gla.ac.uk@pp.dcs.glasgow.ac.uk> +To: glasgow-haskell-bugs +Subject: Unfriendly error message +Date: Thu, 25 Jun 1992 09:22:55 +0100 + +Hello again, + +I came across a rather nasty error message when I gave a function an +incorrect type signature (the context is wrong). I can remember reading +in the source about this problem - I just thought I'd let you know anyway :-) +-} +module ShouldFail where + + +test::(Num a, Eq a) => a -> Bool +test x = (x `mod` 3) == 0 + +{- +granite> ndph bug002.ldh +Data Parallel Haskell Compiler, version 0.01 (Glasgow 0.07) + + +"<unknown>", line <unknown>: Cannot express dicts in terms of dictionaries available: +dicts_encl: + "<built-in>", line : dict.87 :: <Num a> + "<built-in>", line : dict.88 :: <Eq a> +dicts_encl': + "<built-in>", line : dict.87 :: <Num a> + "<built-in>", line : dict.88 :: <Eq a> +dicts: + "<built-in>", line : dict.87 :: <Num a> + "<built-in>", line : dict.88 :: <Eq a> +super_class_dict: "<built-in>", line : dict.80 :: <Integral a> +Fail: Compilation errors found + +dph: execution of the Haskell compiler had trouble + +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail034.stderr b/testsuite/tests/typecheck/should_fail/tcfail034.stderr new file mode 100644 index 0000000000..db8e148eb9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail034.stderr @@ -0,0 +1,12 @@ + +tcfail034.hs:17:13: + Could not deduce (Integral a) arising from a use of `mod' + from the context (Num a, Eq a) + bound by the type signature for test :: (Num a, Eq a) => a -> Bool + at tcfail034.hs:17:1-25 + Possible fix: + add (Integral a) to the context of + the type signature for test :: (Num a, Eq a) => a -> Bool + In the first argument of `(==)', namely `(x `mod` 3)' + In the expression: (x `mod` 3) == 0 + In an equation for `test': test x = (x `mod` 3) == 0 diff --git a/testsuite/tests/typecheck/should_fail/tcfail035.hs b/testsuite/tests/typecheck/should_fail/tcfail035.hs new file mode 100644 index 0000000000..8de67867dd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail035.hs @@ -0,0 +1,9 @@ +-- !!! instances with empty where parts: duplicate +-- +module ShouldFail where + +data NUM = ONE | TWO +instance Num NUM +instance Num NUM +instance Eq NUM +instance Show NUM diff --git a/testsuite/tests/typecheck/should_fail/tcfail035.stderr b/testsuite/tests/typecheck/should_fail/tcfail035.stderr new file mode 100644 index 0000000000..ed9efb53b0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail035.stderr @@ -0,0 +1,5 @@ + +tcfail035.hs:6:10: + Duplicate instance declarations: + instance Num NUM -- Defined at tcfail035.hs:6:10-16 + instance Num NUM -- Defined at tcfail035.hs:7:10-16 diff --git a/testsuite/tests/typecheck/should_fail/tcfail035.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail035.stderr-hugs new file mode 100644 index 0000000000..4d459748ac --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail035.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail035.hs":7 - Overlapping instances for class "Num" +*** This instance : Num NUM +*** Overlaps with : Num NUM +*** Common instance : Num NUM diff --git a/testsuite/tests/typecheck/should_fail/tcfail036.hs b/testsuite/tests/typecheck/should_fail/tcfail036.hs new file mode 100644 index 0000000000..ade1720ccc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail036.hs @@ -0,0 +1,10 @@ +-- !!! prelude class name in an instance-tycon position +-- +module ShouldFail where + +data NUM = ONE | TWO +instance Num NUM + where ONE + ONE = TWO +instance Num NUM +instance Eq Num +--instance Text Num diff --git a/testsuite/tests/typecheck/should_fail/tcfail036.stderr b/testsuite/tests/typecheck/should_fail/tcfail036.stderr new file mode 100644 index 0000000000..9ce51d2dd0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail036.stderr @@ -0,0 +1,9 @@ + +tcfail036.hs:6:10: + Duplicate instance declarations: + instance Num NUM -- Defined at tcfail036.hs:6:10-16 + instance Num NUM -- Defined at tcfail036.hs:8:10-16 + +tcfail036.hs:9:13: + Class `Num' used as a type + In the instance declaration for `Eq Num' diff --git a/testsuite/tests/typecheck/should_fail/tcfail036.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail036.stderr-hugs new file mode 100644 index 0000000000..7c418cc655 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail036.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail036.hs":8 - Overlapping instances for class "Num" +*** This instance : Num NUM +*** Overlaps with : Num NUM +*** Common instance : Num NUM diff --git a/testsuite/tests/typecheck/should_fail/tcfail037.hs b/testsuite/tests/typecheck/should_fail/tcfail037.hs new file mode 100644 index 0000000000..d2110c755a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail037.hs @@ -0,0 +1,11 @@ +-- !!! PreludeCore entities cannot be redefined at the top-level +-- +module ShouldFail where + +data NUM = ONE | TWO + +f a b = a + b +f :: NUM -> NUM -> NUM + +ONE + ONE = TWO + diff --git a/testsuite/tests/typecheck/should_fail/tcfail037.stderr b/testsuite/tests/typecheck/should_fail/tcfail037.stderr new file mode 100644 index 0000000000..a6a2a5e412 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail037.stderr @@ -0,0 +1,5 @@ + +tcfail037.hs:7:11: + Ambiguous occurrence `+' + It could refer to either `ShouldFail.+', defined at tcfail037.hs:10:5 + or `Prelude.+', imported from Prelude diff --git a/testsuite/tests/typecheck/should_fail/tcfail037.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail037.stderr-hugs new file mode 100644 index 0000000000..cfd3f42a89 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail037.stderr-hugs @@ -0,0 +1,2 @@ +ERROR "tcfail037.hs":7 - Ambiguous variable occurrence "+" +*** Could refer to: ShouldFail.+ Hugs.Prelude.+ diff --git a/testsuite/tests/typecheck/should_fail/tcfail038.hs b/testsuite/tests/typecheck/should_fail/tcfail038.hs new file mode 100644 index 0000000000..1770bde61c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail038.hs @@ -0,0 +1,11 @@ +-- !!! duplicate class-method declarations + +module ShouldFail where + +data NUM = ONE | TWO +instance Eq NUM where + a == b = True + a /= b = False + a == b = False + a /= b = True + diff --git a/testsuite/tests/typecheck/should_fail/tcfail038.stderr b/testsuite/tests/typecheck/should_fail/tcfail038.stderr new file mode 100644 index 0000000000..70e13f3c72 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail038.stderr @@ -0,0 +1,10 @@ + +tcfail038.hs:7:11: + Conflicting definitions for `==' + Bound at: tcfail038.hs:7:11-12 + tcfail038.hs:9:11-12 + +tcfail038.hs:8:11: + Conflicting definitions for `/=' + Bound at: tcfail038.hs:8:11-12 + tcfail038.hs:10:11-12 diff --git a/testsuite/tests/typecheck/should_fail/tcfail038.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail038.stderr-hugs new file mode 100644 index 0000000000..7e2f61b981 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail038.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail038.hs":8 - "/=" multiply defined diff --git a/testsuite/tests/typecheck/should_fail/tcfail040.hs b/testsuite/tests/typecheck/should_fail/tcfail040.hs new file mode 100644 index 0000000000..8ac06b363c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail040.hs @@ -0,0 +1,29 @@ +-- !!! instances of functions +-- +module ShouldFail where + +data NUM = ONE | TWO + +class EQ a where + (===) :: a -> a -> Bool + +class ORD a where + (<<) :: a -> a -> Bool + a << b = True + +instance EQ (a -> b) where + f === g = True + +instance ORD (a -> b) + +f = (<<) === (<<) +--f :: (EQ a,Num a) => a -> a -> Bool + + +{- +instance EQ NUM where +-- a /= b = False + a === b = True +-- a /= b = False + +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail040.stderr b/testsuite/tests/typecheck/should_fail/tcfail040.stderr new file mode 100644 index 0000000000..8d30ec57a2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail040.stderr @@ -0,0 +1,8 @@ + +tcfail040.hs:19:14: + Ambiguous type variable `a0' in the constraint: + (ORD a0) arising from a use of `<<' + Probable fix: add a type signature that fixes these type variable(s) + In the second argument of `(===)', namely `(<<)' + In the expression: (<<) === (<<) + In an equation for `f': f = (<<) === (<<) diff --git a/testsuite/tests/typecheck/should_fail/tcfail040.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail040.stderr-hugs new file mode 100644 index 0000000000..2a12f6a15b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail040.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail040.hs":19 - Unresolved top-level overloading +*** Binding : f +*** Outstanding context : ORD b diff --git a/testsuite/tests/typecheck/should_fail/tcfail042.hs b/testsuite/tests/typecheck/should_fail/tcfail042.hs new file mode 100644 index 0000000000..5fdf6c61b6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail042.hs @@ -0,0 +1,30 @@ +module ShouldFail where + +-- !!! weird class/instance examples off the haskell list +-- + +class Foo a where foo :: a -> a +class Foo a => Bar a where bar :: a -> a + + +instance Num a => Foo [a] where + foo [] = [] + foo (x:xs) = map (x+) xs + + +instance (Eq a, Show a) => Bar [a] where + bar [] = [] + bar (x:xs) = foo xs where u = x==x + v = show x + +------------------------------------------ + +{- +class Foo a => Bar2 a where bar2 :: a -> a + +instance (Eq a, Show a) => Foo [a] + +instance Num a => Bar2 [a] + +data X a = X a +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail042.stderr b/testsuite/tests/typecheck/should_fail/tcfail042.stderr new file mode 100644 index 0000000000..ba2b83fd96 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail042.stderr @@ -0,0 +1,24 @@ + +tcfail042.hs:15:10: + Could not deduce (Num a) + arising from the superclasses of an instance declaration + from the context (Eq a, Show a) + bound by the instance declaration at tcfail042.hs:15:10-34 + Possible fix: + add (Num a) to the context of the instance declaration + In the instance declaration for `Bar [a]' + +tcfail042.hs:17:18: + Could not deduce (Num a) arising from a use of `foo' + from the context (Eq a, Show a) + bound by the instance declaration at tcfail042.hs:15:10-34 + Possible fix: + add (Num a) to the context of the instance declaration + In the expression: foo xs + In an equation for `bar': + bar (x : xs) + = foo xs + where + u = x == x + v = show x + In the instance declaration for `Bar [a]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail042.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail042.stderr-hugs new file mode 100644 index 0000000000..87c290d829 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail042.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail042.hs":15 - Cannot build superclass instance +*** Instance : Bar [a] +*** Context supplied : (Eq a, Show a) +*** Required superclass : Foo [a] diff --git a/testsuite/tests/typecheck/should_fail/tcfail043.hs b/testsuite/tests/typecheck/should_fail/tcfail043.hs new file mode 100644 index 0000000000..184a4e23bf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail043.hs @@ -0,0 +1,219 @@ +-- The translation of this program should assign only one dictionary to +-- the function search (an Ord dictionary). Instead, it assigns two. +-- The output produced currently displays this. + +-- 10/12/92: This program is actually erroneous. The pattern-binding for +-- search falls under the monomorphism restriction, and there is no +-- call to search which might fix its type. So there should be a complaint. +-- But the actual error message is horrible: +-- +-- "bug001.hs", line 26: Ambiguous overloading: +-- class "Ord_", type "a" (at a use of an overloaded identifier: gt) +-- class "Eq_", type "a" (at a use of an overloaded identifier: eq) + + +module TcFail where + +class Eq_ a where + eq :: a -> a -> Bool + +instance Eq_ Int where + eq = eqIntEq + +instance (Eq_ a) => Eq_ [a] where + eq = \ xs ys -> + if (null xs) + then (null ys) + else if (null ys) + then False + else (&&) (eq (hd xs) (hd ys)) (eq (tl xs) (tl ys)) + +class (Eq_ a) => Ord_ a where + gt :: a -> a -> Bool + +instance Ord_ Int where + gt = ordIntGt + +search + = \ a bs -> if gt (hd bs) a + then False + else if eq a (hd bs) then True else search a (tl bs) + + +hd :: [a] -> a +hd (a:as) = a + +tl :: [a] -> [a] +tl (a:as) = as + +ordIntGt :: Int -> Int -> Bool +ordIntGt 2 3 = True + +eqIntEq :: Int -> Int -> Bool +eqIntEq 2 3 = True + + + + +{- + +=============================================== +Main.Eq__INST_PreludeBuiltin.Int = + let + AbsBinds [] [] [(eq, eq)] + {- nonrec -} + {-# LINE 2 "test3.hs" -} + + eq :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool + eq = Main.eqIntEq + in ({-dict-} [] [eq]) + +Main.Eq__INST_PreludeBuiltin.List = + /\ t135 -> + \{-dict-} _dict138 -> + let + {- nonrec -} + _dict136 = {-singleDict-} _dict138 + {- nonrec -} + _dict129 = {-singleDict-} _dict136 + AbsBinds [] [] [(eq, eq)] + {- nonrec -} + + _dict133 = + Main.Eq__INST_PreludeBuiltin.List + [t135] [{-singleDict-} _dict136] + {- nonrec -} + {-# LINE 5 "test3.hs" -} + + eq :: [t135] -> [t135] -> PreludeCore.Bool + eq = \ xs ys -> + +if (Main.null t135) xs then + (Main.null t135) ys + else + + if (Main.null t135) ys then + PreludeCore.False + else + + Main.and + + + ((Main.Eq_.eq t135 _dict129) + + + ((Main.hd t135) xs) + ((Main.hd t135) ys)) + + + + + + +(Main.Eq_.eq [t135] _dict133) + + + + ((Main.tl t135) xs) + ((Main.tl t135) ys)) + in ({-dict-} [] [eq]) +Main.Ord__INST_PreludeBuiltin.Int = + let + {- nonrec -} + _dict142 = Main.Eq__INST_PreludeBuiltin.Int [] [] + AbsBinds [] [] [(gt, gt)] + {- nonrec -} + {-# LINE 16 "test3.hs" -} + + gt :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool + gt = Main.ordIntGt + in ({-dict-} [_dict142] [gt]) + +Main.Eq_.eq = /\ a -> \{-classdict-} [] [eq] -> eq + +Main.Ord_.gt = /\ a -> \{-classdict-} [_dict56] [gt] -> gt + +Main.Ord__TO_Main.Eq_ = /\ a -> \{-classdict-} [_dict58] [gt] -> ???_dict58??? + +AbsBinds [t60] [] [(hd, Main.hd)] + {- nonrec -} + + + + hd :: [t60] -> t60 + hd (a PreludeBuiltin.: as) + = a + +AbsBinds [t68] [] [(tl, Main.tl)] + {- nonrec -} + + + + + tl :: [t68] -> [t68] + tl (a PreludeBuiltin.: as) + = as + + +AbsBinds [t91] [_dict85, _dict88] [(search, Main.search)] + {- rec -} + {-# LINE 19 "test3.hs" -} + + + search :: t91 -> [t91] -> PreludeCore.Bool + search + = \ a bs -> + + +if (Main.Ord_.gt t91 _dict85) ((Main.hd t91) bs) a then + PreludeCore.False + else + + if (Main.Eq_.eq t91 _dict88) a ((Main.hd t91) bs) then + PreludeCore.True + else + + search a ((Main.tl t91) bs) +AbsBinds [] [] [(and, Main.and)] + {- nonrec -} + and :: PreludeCore.Bool -> PreludeCore.Bool -> PreludeCore.Bool + and PreludeCore.True PreludeCore.True + = PreludeCore.True +AbsBinds [] [] [(ordIntGt, Main.ordIntGt)] + {- nonrec -} + _dict97 = PreludeCore.Num_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict98 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict100 = PreludeCore.Num_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict101 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + + + + ordIntGt :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool + ordIntGt + 2 3 = PreludeCore.True +AbsBinds [] [] [(eqIntEq, Main.eqIntEq)] + {- nonrec -} + _dict105 = PreludeCore.Num_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict106 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict108 = PreludeCore.Num_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + _dict109 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] [] + {- nonrec -} + + eqIntEq :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool + eqIntEq + 2 3 = PreludeCore.True + + +AbsBinds [t112] [] [(null, Main.null)] + {- nonrec -} + + null :: [t112] -> PreludeCore.Bool + null [] = PreludeCore.True +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail043.stderr b/testsuite/tests/typecheck/should_fail/tcfail043.stderr new file mode 100644 index 0000000000..7cd3faf53e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail043.stderr @@ -0,0 +1,21 @@ + +tcfail043.hs:38:17: + Ambiguous type variable `a0' in the constraints: + (Ord_ a0) arising from a use of `gt' at tcfail043.hs:38:17-18 + (Eq_ a0) arising from a use of `eq' at tcfail043.hs:40:25-26 + Possible cause: the monomorphism restriction applied to the following: + search :: a0 -> [a0] -> Bool (bound at tcfail043.hs:37:1) + Probable fix: give these definition(s) an explicit type signature + or use -XNoMonomorphismRestriction + In the expression: gt (hd bs) a + In the expression: + if gt (hd bs) a then + False + else + if eq a (hd bs) then True else search a (tl bs) + In the expression: + \ a bs + -> if gt (hd bs) a then + False + else + if eq a (hd bs) then True else search a (tl bs) diff --git a/testsuite/tests/typecheck/should_fail/tcfail043.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail043.stderr-hugs new file mode 100644 index 0000000000..2153721a6d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail043.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail043.hs":38 - Unresolved top-level overloading +*** Binding : search +*** Outstanding context : Ord_ b diff --git a/testsuite/tests/typecheck/should_fail/tcfail044.hs b/testsuite/tests/typecheck/should_fail/tcfail044.hs new file mode 100644 index 0000000000..b271d0f977 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail044.hs @@ -0,0 +1,22 @@ +-- !!! tcfail044: duplicated type variable in instance decls +-- +module ShouldFail where + +instance (Eq a) => Eq (a->a) +instance Show (a->b) + +instance (Num a) => Num (a->a) where + f + g = \x -> f x + g x + negate f = \x -> - (f x) + f * g = \x -> f x * g x + fromInteger n = \x -> fromInteger n + +ss :: Float -> Float +cc :: Float -> Float +tt :: Float -> Float + +ss = sin * sin +cc = cos * cos +tt = ss + cc + +--main = putStr ((show (tt 0.4))++ " "++(show (tt 1.652))) diff --git a/testsuite/tests/typecheck/should_fail/tcfail044.stderr b/testsuite/tests/typecheck/should_fail/tcfail044.stderr new file mode 100644 index 0000000000..03ad2fb705 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail044.stderr @@ -0,0 +1,16 @@ + +tcfail044.hs:5:20: + Illegal instance declaration for `Eq (a -> a)' + (All instance types must be of the form (T a1 ... an) + where a1 ... an are *distinct type variables*, + and each type variable appears at most once in the instance head. + Use -XFlexibleInstances if you want to disable this.) + In the instance declaration for `Eq (a -> a)' + +tcfail044.hs:8:21: + Illegal instance declaration for `Num (a -> a)' + (All instance types must be of the form (T a1 ... an) + where a1 ... an are *distinct type variables*, + and each type variable appears at most once in the instance head. + Use -XFlexibleInstances if you want to disable this.) + In the instance declaration for `Num (a -> a)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail044.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail044.stderr-hugs new file mode 100644 index 0000000000..6fe05624cd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail044.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail044.hs":5 - Repeated type variable "a" in instance head diff --git a/testsuite/tests/typecheck/should_fail/tcfail046.hs b/testsuite/tests/typecheck/should_fail/tcfail046.hs new file mode 100644 index 0000000000..67225acde0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail046.hs @@ -0,0 +1,27 @@ +-- !! function types in deriving Eq things +-- From a bug report by Dave Harrison <D.A.Harrison@newcastle.ac.uk> + +module ShouldFail where + + +type Process a = Pid -> Time -> Message a -> ( MessList a, + Continuation a) + +data Continuation a = Do (Process a) deriving Eq + + +type ProcList a = [ (Pid, Status, Process a) ] +data Status = Active | Passive | Busy Integer | Terminated + deriving Eq + + +data Message a = Create (Process a) | Created Pid | Activate Pid | + Passivate Pid | Terminate Pid | Wait Pid Time | + Query Pid a | Data Pid a | Event | + Output Pid String + deriving Eq + +type MessList a = [ Message a ] + +type Pid = Integer +type Time = Integer diff --git a/testsuite/tests/typecheck/should_fail/tcfail046.stderr b/testsuite/tests/typecheck/should_fail/tcfail046.stderr new file mode 100644 index 0000000000..1b668d07a6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail046.stderr @@ -0,0 +1,18 @@ + +tcfail046.hs:10:50: + No instance for (Eq (Process a)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (Process a)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Eq (Continuation a)) + +tcfail046.hs:22:25: + No instance for (Eq (Process a)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Eq (Process a)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Eq (Message a)) diff --git a/testsuite/tests/typecheck/should_fail/tcfail046.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail046.stderr-hugs new file mode 100644 index 0000000000..583bd7ffd8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail046.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail046.hs":9 - An instance of Eq (Process a) is required to derive Eq (Continuation a) diff --git a/testsuite/tests/typecheck/should_fail/tcfail047.hs b/testsuite/tests/typecheck/should_fail/tcfail047.hs new file mode 100644 index 0000000000..f3cdb19741 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail047.hs @@ -0,0 +1,7 @@ +module ShouldFail where + +class A a where + op1 :: a -> a + +instance A (a,(b,c)) where + op1 a = a diff --git a/testsuite/tests/typecheck/should_fail/tcfail047.stderr b/testsuite/tests/typecheck/should_fail/tcfail047.stderr new file mode 100644 index 0000000000..e99d9df755 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail047.stderr @@ -0,0 +1,8 @@ + +tcfail047.hs:6:10: + Illegal instance declaration for `A (a, (b, c))' + (All instance types must be of the form (T a1 ... an) + where a1 ... an are *distinct type variables*, + and each type variable appears at most once in the instance head. + Use -XFlexibleInstances if you want to disable this.) + In the instance declaration for `A (a, (b, c))' diff --git a/testsuite/tests/typecheck/should_fail/tcfail047.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail047.stderr-hugs new file mode 100644 index 0000000000..8b2a529fe8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail047.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail047.hs":6 - Syntax error in instance head (variable expected) diff --git a/testsuite/tests/typecheck/should_fail/tcfail048.hs b/testsuite/tests/typecheck/should_fail/tcfail048.hs new file mode 100644 index 0000000000..f4400e2fa0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail048.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +class (B a) => C a where + op1 :: a -> a diff --git a/testsuite/tests/typecheck/should_fail/tcfail048.stderr b/testsuite/tests/typecheck/should_fail/tcfail048.stderr new file mode 100644 index 0000000000..569b85f915 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail048.stderr @@ -0,0 +1,2 @@ + +tcfail048.hs:3:7: Not in scope: type constructor or class `B' diff --git a/testsuite/tests/typecheck/should_fail/tcfail048.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail048.stderr-hugs new file mode 100644 index 0000000000..8ae3da6dea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail048.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail048.hs":3 - Undefined class "B" diff --git a/testsuite/tests/typecheck/should_fail/tcfail049.hs b/testsuite/tests/typecheck/should_fail/tcfail049.hs new file mode 100644 index 0000000000..64dee54a5c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail049.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = g x diff --git a/testsuite/tests/typecheck/should_fail/tcfail049.stderr b/testsuite/tests/typecheck/should_fail/tcfail049.stderr new file mode 100644 index 0000000000..750a65bc3c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail049.stderr @@ -0,0 +1,2 @@ + +tcfail049.hs:3:7: Not in scope: `g' diff --git a/testsuite/tests/typecheck/should_fail/tcfail049.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail049.stderr-hugs new file mode 100644 index 0000000000..95c25d66e3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail049.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail049.hs":3 - Undefined variable "g" diff --git a/testsuite/tests/typecheck/should_fail/tcfail050.hs b/testsuite/tests/typecheck/should_fail/tcfail050.hs new file mode 100644 index 0000000000..c0cee979f7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail050.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = B x diff --git a/testsuite/tests/typecheck/should_fail/tcfail050.stderr b/testsuite/tests/typecheck/should_fail/tcfail050.stderr new file mode 100644 index 0000000000..9115af93fb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail050.stderr @@ -0,0 +1,2 @@ + +tcfail050.hs:3:7: Not in scope: data constructor `B' diff --git a/testsuite/tests/typecheck/should_fail/tcfail050.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail050.stderr-hugs new file mode 100644 index 0000000000..d3153a8875 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail050.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail050.hs":3 - Undefined data constructor "B" diff --git a/testsuite/tests/typecheck/should_fail/tcfail051.hs b/testsuite/tests/typecheck/should_fail/tcfail051.hs new file mode 100644 index 0000000000..1b8e251c40 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail051.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +instance B Bool where + op1 a = a diff --git a/testsuite/tests/typecheck/should_fail/tcfail051.stderr b/testsuite/tests/typecheck/should_fail/tcfail051.stderr new file mode 100644 index 0000000000..97d4b13a1e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail051.stderr @@ -0,0 +1,4 @@ + +tcfail051.hs:3:10: Not in scope: type constructor or class `B' + +tcfail051.hs:4:2: `op1' is not a (visible) method of class `B' diff --git a/testsuite/tests/typecheck/should_fail/tcfail051.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail051.stderr-hugs new file mode 100644 index 0000000000..6f6d9689cd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail051.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail051.hs":3 - Undefined class "B" diff --git a/testsuite/tests/typecheck/should_fail/tcfail052.hs b/testsuite/tests/typecheck/should_fail/tcfail052.hs new file mode 100644 index 0000000000..e9be21e6f2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail052.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +data C a = B a c diff --git a/testsuite/tests/typecheck/should_fail/tcfail052.stderr b/testsuite/tests/typecheck/should_fail/tcfail052.stderr new file mode 100644 index 0000000000..9ffa31c227 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail052.stderr @@ -0,0 +1,2 @@ + +tcfail052.hs:3:16: Not in scope: type variable `c' diff --git a/testsuite/tests/typecheck/should_fail/tcfail052.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail052.stderr-hugs new file mode 100644 index 0000000000..57866de750 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail052.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail052.hs":3 - Undefined type variable "c" diff --git a/testsuite/tests/typecheck/should_fail/tcfail053.hs b/testsuite/tests/typecheck/should_fail/tcfail053.hs new file mode 100644 index 0000000000..d13e606434 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail053.hs @@ -0,0 +1,3 @@ +module TcFail where + +data B = C A diff --git a/testsuite/tests/typecheck/should_fail/tcfail053.stderr b/testsuite/tests/typecheck/should_fail/tcfail053.stderr new file mode 100644 index 0000000000..9889c3f0f6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail053.stderr @@ -0,0 +1,2 @@ + +tcfail053.hs:3:12: Not in scope: type constructor or class `A' diff --git a/testsuite/tests/typecheck/should_fail/tcfail053.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail053.stderr-hugs new file mode 100644 index 0000000000..85bd6abcc6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail053.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail053.hs":3 - Undefined type constructor "A" diff --git a/testsuite/tests/typecheck/should_fail/tcfail054.hs b/testsuite/tests/typecheck/should_fail/tcfail054.hs new file mode 100644 index 0000000000..a4e724cf18 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail054.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f (B a) = True diff --git a/testsuite/tests/typecheck/should_fail/tcfail054.stderr b/testsuite/tests/typecheck/should_fail/tcfail054.stderr new file mode 100644 index 0000000000..1a5cfca053 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail054.stderr @@ -0,0 +1,2 @@ + +tcfail054.hs:3:4: Not in scope: data constructor `B' diff --git a/testsuite/tests/typecheck/should_fail/tcfail054.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail054.stderr-hugs new file mode 100644 index 0000000000..2a20bb69d2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail054.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail054.hs":3 - Undefined data constructor "B" diff --git a/testsuite/tests/typecheck/should_fail/tcfail055.hs b/testsuite/tests/typecheck/should_fail/tcfail055.hs new file mode 100644 index 0000000000..f61c5a81be --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail055.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = (x + 1 :: Int) :: Float diff --git a/testsuite/tests/typecheck/should_fail/tcfail055.stderr b/testsuite/tests/typecheck/should_fail/tcfail055.stderr new file mode 100644 index 0000000000..ac012da98e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail055.stderr @@ -0,0 +1,5 @@ + +tcfail055.hs:3:8: + Couldn't match expected type `Float' with actual type `Int' + In the expression: (x + 1 :: Int) :: Float + In an equation for `f': f x = (x + 1 :: Int) :: Float diff --git a/testsuite/tests/typecheck/should_fail/tcfail055.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail055.stderr-hugs new file mode 100644 index 0000000000..c9d13c2991 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail055.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail055.hs":3 - Type error in type annotation +*** Term : x + 1 +*** Type : Int +*** Does not match : Float diff --git a/testsuite/tests/typecheck/should_fail/tcfail056.hs b/testsuite/tests/typecheck/should_fail/tcfail056.hs new file mode 100644 index 0000000000..a8a1315be7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail056.hs @@ -0,0 +1,11 @@ +module ShouldFail where + +data Foo = MkFoo Bool + +instance Eq Foo where + (MkFoo x) == (MkFoo y) = x == y + +instance Eq Foo where + -- forgot to type "Ord" above + (MkFoo x) <= (MkFoo y) = x <= y + diff --git a/testsuite/tests/typecheck/should_fail/tcfail056.stderr b/testsuite/tests/typecheck/should_fail/tcfail056.stderr new file mode 100644 index 0000000000..09505ed945 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail056.stderr @@ -0,0 +1,2 @@ + +tcfail056.hs:10:15: `<=' is not a (visible) method of class `Eq' diff --git a/testsuite/tests/typecheck/should_fail/tcfail056.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail056.stderr-hugs new file mode 100644 index 0000000000..d1521e1a78 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail056.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail056.hs":8 - Overlapping instances for class "Eq" +*** This instance : Eq Foo +*** Overlaps with : Eq Foo +*** Common instance : Eq Foo diff --git a/testsuite/tests/typecheck/should_fail/tcfail057.hs b/testsuite/tests/typecheck/should_fail/tcfail057.hs new file mode 100644 index 0000000000..9659cf0801 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail057.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- !!! inadvertently using -> instead of => + +f :: (RealFrac a) -> a -> a +f x = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail057.stderr b/testsuite/tests/typecheck/should_fail/tcfail057.stderr new file mode 100644 index 0000000000..d67b969f37 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail057.stderr @@ -0,0 +1,5 @@ + +tcfail057.hs:5:7: + Class `RealFrac' used as a type + In the type signature for `f': + f :: (RealFrac a) -> a -> a diff --git a/testsuite/tests/typecheck/should_fail/tcfail057.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail057.stderr-hugs new file mode 100644 index 0000000000..c18a43df4a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail057.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail057.hs":5 - Undefined type constructor "RealFrac" diff --git a/testsuite/tests/typecheck/should_fail/tcfail058.hs b/testsuite/tests/typecheck/should_fail/tcfail058.hs new file mode 100644 index 0000000000..2763e97bc7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail058.hs @@ -0,0 +1,7 @@ +module ShouldFail where +import Data.Array + +-- !!! inadvertently using => instead of -> + +f :: (Array a) => a -> b +f x = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail058.stderr b/testsuite/tests/typecheck/should_fail/tcfail058.stderr new file mode 100644 index 0000000000..4c017c8681 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail058.stderr @@ -0,0 +1,4 @@ +
+tcfail058.hs:6:6:
+ Type constructor `Array' used as a class
+ In the type signature for `f': f :: Array a => a -> b
diff --git a/testsuite/tests/typecheck/should_fail/tcfail058.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail058.stderr-hugs new file mode 100644 index 0000000000..dee94737b2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail058.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail058.hs":6 - Undefined class "Array" diff --git a/testsuite/tests/typecheck/should_fail/tcfail061.hs b/testsuite/tests/typecheck/should_fail/tcfail061.hs new file mode 100644 index 0000000000..35e502c64e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail061.hs @@ -0,0 +1,11 @@ +-- !! signature bugs exposed by Sigbjorn Finne +-- +module ShouldFail where + +type Flarp a = (b,b) + +--More fun can be had if we change the signature slightly + +type Bob a = a + +type Flarp2 a = Bob (b,b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail061.stderr b/testsuite/tests/typecheck/should_fail/tcfail061.stderr new file mode 100644 index 0000000000..a047863e9b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail061.stderr @@ -0,0 +1,8 @@ + +tcfail061.hs:5:17: Not in scope: type variable `b' + +tcfail061.hs:5:19: Not in scope: type variable `b' + +tcfail061.hs:11:22: Not in scope: type variable `b' + +tcfail061.hs:11:24: Not in scope: type variable `b' diff --git a/testsuite/tests/typecheck/should_fail/tcfail061.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail061.stderr-hugs new file mode 100644 index 0000000000..47faffae38 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail061.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail061.hs":11 - Undefined type variable "b" diff --git a/testsuite/tests/typecheck/should_fail/tcfail062.hs b/testsuite/tests/typecheck/should_fail/tcfail062.hs new file mode 100644 index 0000000000..f37dc1e556 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail062.hs @@ -0,0 +1,37 @@ +-- !!! bug report from Satnam +-- +module ShouldFail +where + +type Module = (String,[Declaration]) + +data Declaration + = Architecture String StructuralExpression | + Behaviour String Parameter Parameter BehaviouralExpression + deriving (Eq, Show) + +data Parameter = ParameterVariable String | ParameterList [Parameter] + deriving (Eq, Show) + +nameOfModule :: Module -> String +nameOfModule (name, _) = name + +data StructuralExpression + = Variable String | + Serial StructuralExpression StructuralExpression | + Par [StructuralExpression] + deriving (Eq, Show) + +data BehaviouralExpression + = BehaviouralVariable String + | AndExpr BehaviouralExpression BehaviouralExpression + | OrExpr BehaviouralExpression BehaviouralExpression + | NotExpr BehaviouralExpression + deriving (Eq, Show) + + +type BehaviouralRelation + = (behaviouralExpression, behaviouralExpression) +---- ^ typo ----------------^ typo (but so what?) + +type BehaviouralRelationList = [BehaviouralRelation] diff --git a/testsuite/tests/typecheck/should_fail/tcfail062.stderr b/testsuite/tests/typecheck/should_fail/tcfail062.stderr new file mode 100644 index 0000000000..9ee1bb75a9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail062.stderr @@ -0,0 +1,6 @@ + +tcfail062.hs:34:6: + Not in scope: type variable `behaviouralExpression' + +tcfail062.hs:34:29: + Not in scope: type variable `behaviouralExpression' diff --git a/testsuite/tests/typecheck/should_fail/tcfail062.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail062.stderr-hugs new file mode 100644 index 0000000000..261199229e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail062.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail062.hs":34 - Undefined type variable "behaviouralExpression" diff --git a/testsuite/tests/typecheck/should_fail/tcfail063.hs b/testsuite/tests/typecheck/should_fail/tcfail063.hs new file mode 100644 index 0000000000..6e012dbb24 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail063.hs @@ -0,0 +1,7 @@ +-- !!! no type variable on a context +-- !!! reported by Sigbjorn Finne + +module ShouldFail where + +moby :: Num => Int -> a -> Int +moby x y = x+y diff --git a/testsuite/tests/typecheck/should_fail/tcfail063.stderr b/testsuite/tests/typecheck/should_fail/tcfail063.stderr new file mode 100644 index 0000000000..1a1ee507f5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail063.stderr @@ -0,0 +1,5 @@ + +tcfail063.hs:6:9: + `Num' is not applied to enough type arguments + Expected kind `?', but `Num' has kind `* -> *' + In the type signature for `moby': moby :: Num => Int -> a -> Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail063.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail063.stderr-hugs new file mode 100644 index 0000000000..3ddc482a66 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail063.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail063.hs":6 - Haskell 98 does not support tag classes diff --git a/testsuite/tests/typecheck/should_fail/tcfail065.hs b/testsuite/tests/typecheck/should_fail/tcfail065.hs new file mode 100644 index 0000000000..3029b1978c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail065.hs @@ -0,0 +1,37 @@ +{- + +------- Forwarded Message + +Date: Wed, 30 Nov 1994 16:34:18 +0100 +From: John Hughes <rjmh@cs.chalmers.se> +To: augustss@cs.chalmers.se, simonpj@dcs.gla.ac.uk +Subject: Nice little program + + +Lennart, Simon, + +You might like to look at the fun little program below. + +THUMBS DOWN to hbc for compiling it (it prints [72, 101, 108, 108, 111]) +THUMBS UP to ghc for rejecting it --- but what an error message! +nhc and gofer both reject it with the right error message. +I haven't tried Yale Haskell. + +Enjoy! +- ---------------------------- +-} + +class HasX a where + setX :: x->a->a + +data X x = X x +instance HasX (X x) where + setX x (X _) = X x + +changetype x = case setX x (X (error "change type!")) of X y->y + +main = print (changetype "Hello" :: [Int]) + +{- +------- End of Forwarded Message +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail065.stderr b/testsuite/tests/typecheck/should_fail/tcfail065.stderr new file mode 100644 index 0000000000..9d94b920ff --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail065.stderr @@ -0,0 +1,11 @@ + +tcfail065.hs:29:20: + Couldn't match type `x1' with `x' + `x1' is a rigid type variable bound by + the type signature for setX :: x1 -> X x -> X x + at tcfail065.hs:29:3 + `x' is a rigid type variable bound by + the instance declaration at tcfail065.hs:28:18 + In the first argument of `X', namely `x' + In the expression: X x + In an equation for `setX': setX x (X _) = X x diff --git a/testsuite/tests/typecheck/should_fail/tcfail065.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail065.stderr-hugs new file mode 100644 index 0000000000..ef6178e6f2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail065.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail065.hs":29 - Inferred type is not general enough +*** Expression : setX +*** Expected type : HasX (X a) => b -> X a -> X a +*** Inferred type : HasX (X a) => a -> X a -> X a diff --git a/testsuite/tests/typecheck/should_fail/tcfail067.hs b/testsuite/tests/typecheck/should_fail/tcfail067.hs new file mode 100644 index 0000000000..bcdb0c75ed --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail067.hs @@ -0,0 +1,98 @@ +{-# LANGUAGE DatatypeContexts #-} +module ShouldFail where + +infixr 1 `rangeOf` + +data Ord a => SubRange a = SubRange (a, a) a + +type IntSubRange = SubRange Int + + +subRangeValue :: SubRange a -> a +subRangeValue (SubRange (lower, upper) value) = value + +subRange :: SubRange a -> (a, a) +subRange (SubRange r value) = r + +newRange :: (Ord a, Show a) => (a, a) -> a -> SubRange a +newRange r value = checkRange (SubRange r value) + + +checkRange :: (Ord a, Show a) => SubRange a -> SubRange a +checkRange (SubRange (lower, upper) value) + = if (value < lower) || (value > upper) then + error ("### sub range error. range = " ++ show lower ++ + ".." ++ show upper ++ " value = " ++ show value ++ "\n") + else + SubRange (lower, upper) value + + +instance Eq a => Eq (SubRange a) where + (==) a b = subRangeValue a == subRangeValue b + +instance (Ord a) => Ord (SubRange a) where + (<) = relOp (<) + (<=) = relOp (<=) + (>=) = relOp (>=) + (>) = relOp (>) + +relOp :: Ord a => (a->a->Bool) -> SubRange a -> SubRange a -> Bool +relOp op a b = (subRangeValue a) `op` (subRangeValue b) + +rangeOf :: (Ord a, Show a) => SubRange a -> SubRange a -> SubRange a +rangeOf a b = checkRange (SubRange (subRange b) (subRangeValue a)) + +showRange :: Show a => SubRange a -> String +showRange (SubRange (lower, upper) value) + = show value ++ " :" ++ show lower ++ ".." ++ show upper + +showRangePair :: (Show a, Show b) => (SubRange a, SubRange b) -> String +showRangePair (a, b) + = "(" ++ showRange a ++ ", " ++ showRange b ++ ")" + +showRangeTriple :: (Show a, Show b, Show c) => + (SubRange a, SubRange b, SubRange c) -> String +showRangeTriple (a, b, c) + = "(" ++ showRange a ++ ", " ++ showRange b ++ ", " ++ showRange c ++ ")" + + + +instance Num a => Num (SubRange a) where + negate = numSubRangeNegate + (+) = numSubRangeAdd + (-) = numSubRangeSubtract + (*) = numSubRangeMultiply + fromInteger a = SubRange (fromInteger a, fromInteger a) (fromInteger a) + +numSubRangeNegate :: (Ord a, Num a) => SubRange a -> SubRange a +numSubRangeNegate (SubRange (lower, upper) value) + = checkRange (SubRange (lower, upper) (-value)) + +numSubRangeBinOp :: Num a => (a -> a -> a) -> + SubRange a -> SubRange a -> SubRange a +numSubRangeBinOp op a b + = SubRange (result, result) result + where + result = (subRangeValue a) `op` (subRangeValue b) + +-- partain: +numSubRangeAdd, numSubRangeSubtract, numSubRangeMultiply :: Num a => SubRange a -> SubRange a -> SubRange a + +numSubRangeAdd = numSubRangeBinOp (+) +numSubRangeSubtract = numSubRangeBinOp (-) +numSubRangeMultiply = numSubRangeBinOp (*) + +unsignedBits :: Int -> (Int, Int) +unsignedBits n = (0, 2^n-1) + +signedBits :: Int -> (Int, Int) +signedBits n = (-2^(n-1), 2^(n-1)-1) + + +si_n :: Int -> Int -> IntSubRange +si_n bits value = SubRange (signedBits bits) value + +si8, si10, si16 :: Int -> IntSubRange +si8 = si_n 8 +si10 = si_n 10 +si16 = si_n 16 diff --git a/testsuite/tests/typecheck/should_fail/tcfail067.stderr b/testsuite/tests/typecheck/should_fail/tcfail067.stderr new file mode 100644 index 0000000000..4c69c67391 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail067.stderr @@ -0,0 +1,82 @@ + +tcfail067.hs:1:14: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail067.hs:12:16: + No instance for (Ord a) + arising from a use of `SubRange' + In the pattern: SubRange (lower, upper) value + In an equation for `subRangeValue': + subRangeValue (SubRange (lower, upper) value) = value + +tcfail067.hs:15:11: + No instance for (Ord a) + arising from a use of `SubRange' + In the pattern: SubRange r value + In an equation for `subRange': subRange (SubRange r value) = r + +tcfail067.hs:46:12: + Could not deduce (Ord a) arising from a use of `SubRange' + from the context (Show a) + bound by the type signature for + showRange :: Show a => SubRange a -> String + at tcfail067.hs:(46,1)-(47,58) + Possible fix: + add (Ord a) to the context of + the type signature for showRange :: Show a => SubRange a -> String + In the pattern: SubRange (lower, upper) value + In an equation for `showRange': + showRange (SubRange (lower, upper) value) + = show value ++ " :" ++ show lower ++ ".." ++ show upper + +tcfail067.hs:60:10: + Could not deduce (Show (SubRange a)) + arising from the superclasses of an instance declaration + from the context (Num a) + bound by the instance declaration at tcfail067.hs:60:10-34 + Possible fix: + add (Show (SubRange a)) to the context of the instance declaration + or add an instance declaration for (Show (SubRange a)) + In the instance declaration for `Num (SubRange a)' + +tcfail067.hs:61:12: + Could not deduce (Ord a) arising from a use of `numSubRangeNegate' + from the context (Num a) + bound by the instance declaration at tcfail067.hs:60:10-34 + Possible fix: + add (Ord a) to the context of the instance declaration + In the expression: numSubRangeNegate + In an equation for `negate': negate = numSubRangeNegate + In the instance declaration for `Num (SubRange a)' + +tcfail067.hs:65:19: + Could not deduce (Ord a) arising from a use of `SubRange' + from the context (Num a) + bound by the instance declaration at tcfail067.hs:60:10-34 + Possible fix: + add (Ord a) to the context of the instance declaration + In the expression: + SubRange (fromInteger a, fromInteger a) (fromInteger a) + In an equation for `fromInteger': + fromInteger a + = SubRange (fromInteger a, fromInteger a) (fromInteger a) + In the instance declaration for `Num (SubRange a)' + +tcfail067.hs:74:5: + Could not deduce (Ord a) arising from a use of `SubRange' + from the context (Num a) + bound by the type signature for + numSubRangeBinOp :: Num a => + (a -> a -> a) -> SubRange a -> SubRange a -> SubRange a + at tcfail067.hs:(73,1)-(76,53) + Possible fix: + add (Ord a) to the context of + the type signature for + numSubRangeBinOp :: Num a => + (a -> a -> a) -> SubRange a -> SubRange a -> SubRange a + In the expression: SubRange (result, result) result + In an equation for `numSubRangeBinOp': + numSubRangeBinOp op a b + = SubRange (result, result) result + where + result = (subRangeValue a) `op` (subRangeValue b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail067.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail067.stderr-hugs new file mode 100644 index 0000000000..ac6853972f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail067.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail067.hs":12 - Cannot justify constraints in explicitly typed binding +*** Expression : subRangeValue +*** Type : SubRange a -> a +*** Given context : () +*** Constraints : Ord a diff --git a/testsuite/tests/typecheck/should_fail/tcfail068.hs b/testsuite/tests/typecheck/should_fail/tcfail068.hs new file mode 100644 index 0000000000..beae0f8359 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail068.hs @@ -0,0 +1,90 @@ +-- !! Make sure that state threads don't escape +-- !! (example from Neil Ashton at York) +-- +module ShouldFail where + +import GHC.Arr +import Control.Monad.ST ( runST ) + +type IndTree s t = STArray s (Int,Int) t + +itgen :: Constructed a => (Int,Int) -> a -> IndTree s a +itgen n x = + runST ( + newSTArray ((1,1),n) x) + +itiap :: Constructed a => (Int,Int) -> (a->a) -> IndTree s a -> IndTree s a +itiap i f arr = + runST ( + readSTArray arr i >>= \val -> + writeSTArray arr i (f val) >> + return arr) + +itrap :: Constructed a => ((Int,Int),(Int,Int)) -> (a->a) -> IndTree s a -> IndTree s a +itrap ((i,k),(j,l)) f arr = runST(itrap' i k) + where + itrap' i k = if k > l then return arr + else (itrapsnd i k >> + itrap' i (k+1)) + itrapsnd i k = if i > j then return arr + else (readSTArray arr (i,k) >>= \val -> + writeSTArray arr (i,k) (f val) >> + itrapsnd (i+1) k) + +itrapstate :: Constructed b => ((Int,Int),(Int,Int)) -> (a->b->(a,b)) -> ((Int,Int)->c->a) -> + (a->c) -> c -> IndTree s b -> (c, IndTree s b) +itrapstate ((i,k),(j,l)) f c d s arr = runST(itrapstate' i k s) + where + itrapstate' i k s = if k > l then return (s,arr) + else (itrapstatesnd i k s >>= \(s,arr) -> + itrapstate' i (k+1) s) + itrapstatesnd i k s = if i > j then return (s,arr) + else (readSTArray arr (i,k) >>= \val -> + let (newstate, newval) = f (c (i,k) s) val + in writeSTArray arr (i,k) newval >> + itrapstatesnd (i+1) k (d newstate)) + +-- stuff from Auxiliary: copied here (partain) + +sap :: (a->b) -> (c,a) -> (c,b) +sap f (x,y) = (x, f y) + +fap :: (a->b) -> (a,c) -> (b,c) +fap f (x,y) = (f x, y) + +nonempty :: [a] -> Bool +nonempty [] = False +nonempty (_:_) = True + +-- const :: a -> b -> a +-- const k x = k + +-- id :: a -> a +-- id x = x + +compose :: [a->a] -> a -> a +compose = foldr (.) id + +class Constructed a where + normal :: a -> Bool + +instance Constructed Bool where + normal True = True + normal False = True + +instance Constructed Int where + normal 0 = True + normal n = True + +instance (Constructed a, Constructed b) => Constructed (a,b) where + normal (x,y) = normal x && normal y + +-- pair :: (Constructed a, Constructed b) => a -> b -> (a,b) +-- pair x y | normal x && normal y = (x,y) + +instance Constructed (Maybe a) where + normal Nothing = True + normal (Just _) = True + +just :: Constructed a => a -> Maybe a +just x | normal x = Just x diff --git a/testsuite/tests/typecheck/should_fail/tcfail068.stderr b/testsuite/tests/typecheck/should_fail/tcfail068.stderr new file mode 100644 index 0000000000..afc671a8bf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail068.stderr @@ -0,0 +1,92 @@ + +tcfail068.hs:14:9: + Could not deduce (s1 ~ s) + from the context (Constructed a) + bound by the type signature for + itgen :: Constructed a => (Int, Int) -> a -> IndTree s a + at tcfail068.hs:(12,1)-(14,31) + `s1' is a rigid type variable bound by + a type expected by the context: GHC.ST.ST s1 (IndTree s a) + at tcfail068.hs:13:9 + `s' is a rigid type variable bound by + the type signature for + itgen :: Constructed a => (Int, Int) -> a -> IndTree s a + at tcfail068.hs:12:1 + Expected type: GHC.ST.ST s (IndTree s1 a) + Actual type: GHC.ST.ST s (STArray s (Int, Int) a) + In the return type of a call of `newSTArray' + In the first argument of `runST', namely + `(newSTArray ((1, 1), n) x)' + +tcfail068.hs:20:22: + Could not deduce (s ~ s1) + from the context (Constructed a) + bound by the type signature for + itiap :: Constructed a => + (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a + at tcfail068.hs:(17,1)-(21,19) + `s' is a rigid type variable bound by + the type signature for + itiap :: Constructed a => + (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a + at tcfail068.hs:17:1 + `s1' is a rigid type variable bound by + a type expected by the context: GHC.ST.ST s1 (IndTree s a) + at tcfail068.hs:18:9 + Expected type: STArray s1 (Int, Int) a + Actual type: IndTree s a + In the first argument of `writeSTArray', namely `arr' + In the first argument of `(>>)', namely + `writeSTArray arr i (f val)' + +tcfail068.hs:24:35: + Could not deduce (s ~ s1) + from the context (Constructed a) + bound by the type signature for + itrap :: Constructed a => + ((Int, Int), (Int, Int)) -> (a -> a) -> IndTree s a -> IndTree s a + at tcfail068.hs:(24,1)-(32,41) + `s' is a rigid type variable bound by + the type signature for + itrap :: Constructed a => + ((Int, Int), (Int, Int)) -> (a -> a) -> IndTree s a -> IndTree s a + at tcfail068.hs:24:1 + `s1' is a rigid type variable bound by + a type expected by the context: GHC.ST.ST s1 (IndTree s a) + at tcfail068.hs:24:29 + Expected type: GHC.ST.ST s1 (IndTree s a) + Actual type: GHC.ST.ST s (IndTree s a) + In the return type of a call of `itrap'' + In the first argument of `runST', namely `(itrap' i k)' + +tcfail068.hs:36:46: + Could not deduce (s ~ s1) + from the context (Constructed b) + bound by the type signature for + itrapstate :: Constructed b => + ((Int, Int), (Int, Int)) + -> (a -> b -> (a, b)) + -> ((Int, Int) -> c -> a) + -> (a -> c) + -> c + -> IndTree s b + -> (c, IndTree s b) + at tcfail068.hs:(36,1)-(45,66) + `s' is a rigid type variable bound by + the type signature for + itrapstate :: Constructed b => + ((Int, Int), (Int, Int)) + -> (a -> b -> (a, b)) + -> ((Int, Int) -> c -> a) + -> (a -> c) + -> c + -> IndTree s b + -> (c, IndTree s b) + at tcfail068.hs:36:1 + `s1' is a rigid type variable bound by + a type expected by the context: GHC.ST.ST s1 (c, IndTree s b) + at tcfail068.hs:36:40 + Expected type: GHC.ST.ST s1 (c, IndTree s b) + Actual type: GHC.ST.ST s (c, IndTree s b) + In the return type of a call of `itrapstate'' + In the first argument of `runST', namely `(itrapstate' i k s)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail069.hs b/testsuite/tests/typecheck/should_fail/tcfail069.hs new file mode 100644 index 0000000000..63684fa9db --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail069.hs @@ -0,0 +1,48 @@ +{- +From: Marc van Dongen <dongen@cs.ucc.ie> +Date: Wed, 9 Apr 1997 14:06:39 +0100 (BST) + +I just wanted to report that the erroneous and tiny +program added below can not be compiled within 6MB of +heap (Admitted it can be compiled with a bigger heap). +It was part of a bigger program that could not be +compiled within 20MB of heap. + +[GHC 2.03 and earlier.] Turned out to be a bug in the +error recovery mechanism. + +-} + +module ShouldFail where + +too_much :: [Int] -> [(Int,Int)] -> [(Int,[Int])] -> Bool +too_much ds ((k,m):q1) s0 + = case (list1,list2) of + [] -> error "foo" -- too_much ds q2m s2m + where list1 = ds + list2 = ds + {- + list1 = [k' | k' <- ds, k == k'] + list2 = [k' | k' <- ds, m == k'] + s1 = aas s0 k + raM = [] + raKM = listUnion (\a b -> a) [] [] + s1k = s1 + q1k = raM + s2k = s1 + q2k = raM + s2m = s1 + q2m = raM + s2km = foldr (flip aas) s1 raKM + q2km = raKM + -} + +listUnion :: (v -> v -> Bool) -> [v] -> [v] -> [v] +listUnion _ _ _ + = [] + +aas :: (a,b) -> a -> (a,b) +aas s _ + = s + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail069.stderr b/testsuite/tests/typecheck/should_fail/tcfail069.stderr new file mode 100644 index 0000000000..4c40526b5b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail069.stderr @@ -0,0 +1,7 @@ + +tcfail069.hs:21:7: + Couldn't match expected type `([Int], [Int])' + with actual type `[t0]' + In the pattern: [] + In a case alternative: [] -> error "foo" + In the expression: case (list1, list2) of { [] -> error "foo" } diff --git a/testsuite/tests/typecheck/should_fail/tcfail069.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail069.stderr-hugs new file mode 100644 index 0000000000..4566c1d7a5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail069.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail069.hs":20 - Type error in case pattern +*** Term : [] +*** Type : [a] +*** Does not match : ([Int],[Int]) diff --git a/testsuite/tests/typecheck/should_fail/tcfail070.hs b/testsuite/tests/typecheck/should_fail/tcfail070.hs new file mode 100644 index 0000000000..6cd2a28404 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail070.hs @@ -0,0 +1,16 @@ +{- +From: Wolfgang Drotschmann <drotschm@athene.informatik.uni-bonn.de> +Resent-Date: Thu, 15 May 1997 17:23:09 +0100 + +I'm still using the old ghc-2.01. In one program I ran into a problem +I couldn't fix. But I played around with it, I found a small little +script which reproduces it very well: + +panic! (the `impossible' happened): + tlist +-} + +module TcFail where + +type State = ([Int] Bool) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail070.stderr b/testsuite/tests/typecheck/should_fail/tcfail070.stderr new file mode 100644 index 0000000000..31dd66e77f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail070.stderr @@ -0,0 +1,5 @@ + +tcfail070.hs:15:15: + `[Int]' is applied to too many type arguments + In the type `[Int] Bool' + In the type synonym declaration for `State' diff --git a/testsuite/tests/typecheck/should_fail/tcfail070.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail070.stderr-hugs new file mode 100644 index 0000000000..e96e9fcf6a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail070.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail070.hs":15 - Illegal type "[] Int Bool" in constructor application diff --git a/testsuite/tests/typecheck/should_fail/tcfail071.hs b/testsuite/tests/typecheck/should_fail/tcfail071.hs new file mode 100644 index 0000000000..cbbd25070f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail071.hs @@ -0,0 +1,14 @@ +-- !!! Mis-matched contexts in a mutually recursive group + +{- # LANGUAGE NoRelaxedPolyRec #-} +-- With the new type checker you can't turn off RelaxedPolyRec +-- so this test always succeeds + +module ShouldFail where + +f :: (Ord d) => d -> d +f c = g c + +g :: e -> e +g c = c + where p = f (1 :: Int) diff --git a/testsuite/tests/typecheck/should_fail/tcfail071.stderr b/testsuite/tests/typecheck/should_fail/tcfail071.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail071.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail072.hs b/testsuite/tests/typecheck/should_fail/tcfail072.hs new file mode 100644 index 0000000000..501976e5be --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail072.hs @@ -0,0 +1,24 @@ +{- This program crashed GHC 2.03 + + From: Marc van Dongen <dongen@cs.ucc.ie> + Date: Sat, 31 May 1997 14:35:40 +0100 (BST) + + zonkIdOcc: g_aoQ + + panic! (the `impossible' happened): + lookupBindC:no info! + for: g_aoQ + (probably: data dependencies broken by an optimisation pass) + static binds for: + Tmp.$d1{-rmM,x-} + local binds for: +-} + +module ShouldFail where + +data AB p q = A + | B p q + +g :: (Ord p,Ord q) => (AB p q) -> Bool +g (B _ _) = g A + diff --git a/testsuite/tests/typecheck/should_fail/tcfail072.stderr b/testsuite/tests/typecheck/should_fail/tcfail072.stderr new file mode 100644 index 0000000000..469e75849a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail072.stderr @@ -0,0 +1,14 @@ + +tcfail072.hs:23:13: + Ambiguous type variable `p0' in the constraint: + (Ord p0) arising from a use of `g' + Probable fix: add a type signature that fixes these type variable(s) + In the expression: g A + In an equation for `g': g (B _ _) = g A + +tcfail072.hs:23:13: + Ambiguous type variable `q0' in the constraint: + (Ord q0) arising from a use of `g' + Probable fix: add a type signature that fixes these type variable(s) + In the expression: g A + In an equation for `g': g (B _ _) = g A diff --git a/testsuite/tests/typecheck/should_fail/tcfail072.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail072.stderr-hugs new file mode 100644 index 0000000000..57ea305406 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail072.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail072.hs":23 - Cannot justify constraints in explicitly typed binding +*** Expression : g +*** Type : (Ord a, Ord b) => AB a b -> Bool +*** Given context : (Ord a, Ord b) +*** Constraints : (Ord c, Ord d) diff --git a/testsuite/tests/typecheck/should_fail/tcfail073.hs b/testsuite/tests/typecheck/should_fail/tcfail073.hs new file mode 100644 index 0000000000..c52d39ae08 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail073.hs @@ -0,0 +1,10 @@ +-- what error do you get if you redefined Prelude instances? + +module ShouldFail where + +f :: (Eq a) => (a,a) -> (a,a) -> Bool +f x y = x == y + +instance Eq a => Eq (a,b) where + (m,n) == (o,p) = m == o + diff --git a/testsuite/tests/typecheck/should_fail/tcfail073.stderr b/testsuite/tests/typecheck/should_fail/tcfail073.stderr new file mode 100644 index 0000000000..4d3bef99ac --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail073.stderr @@ -0,0 +1,5 @@ +
+tcfail073.hs:8:10:
+ Duplicate instance declarations:
+ instance Eq a => Eq (a, b) -- Defined at tcfail073.hs:8:10-25
+ instance (Eq a, Eq b) => Eq (a, b) -- Defined in GHC.Classes
diff --git a/testsuite/tests/typecheck/should_fail/tcfail073.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail073.stderr-hugs new file mode 100644 index 0000000000..8148b896ae --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail073.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail073.hs":8 - Overlapping instances for class "Eq" +*** This instance : Eq (a,b) +*** Overlaps with : Eq (a,b) +*** Common instance : Eq (a,b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail075.hs b/testsuite/tests/typecheck/should_fail/tcfail075.hs new file mode 100644 index 0000000000..c14f276b2d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail075.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE MagicHash #-} + +-- !!! Test top-level unboxed types + +module ShouldFail where + +import GHC.Base +import GHC.Prim + +x = 1# + +y :: Int# +y = x +# 1# + +main = let + z = x -# y + in + if z ># 3# then putStrLn "Yes" + else putStrLn "No" + diff --git a/testsuite/tests/typecheck/should_fail/tcfail075.stderr b/testsuite/tests/typecheck/should_fail/tcfail075.stderr new file mode 100644 index 0000000000..2c251a7a84 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail075.stderr @@ -0,0 +1,6 @@ + +tcfail075.hs:10:1: + Top-level bindings for unlifted types aren't allowed: x = 1# + +tcfail075.hs:13:1: + Top-level bindings for unlifted types aren't allowed: y = x +# 1# diff --git a/testsuite/tests/typecheck/should_fail/tcfail076.hs b/testsuite/tests/typecheck/should_fail/tcfail076.hs new file mode 100644 index 0000000000..abe96c5640 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail076.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE Rank2Types #-} + +{- + From: Ralf Hinze <ralf@uran.informatik.uni-bonn.de> + Date: Fri, 15 Aug 1997 15:20:51 +0200 (MET DST) + +I *suppose* that there is a bug in GHC's type checker. The following +program, which I think is ill-typed, passes silently the type checker. +Needless to say that it uses some of GHC's arcane type extensions. +-} + +module ShouldFail where + +data ContT m a = KContT (forall res. (a -> m res) -> m res) +unKContT (KContT x) = x + +callcc :: ((a -> ContT m b) -> ContT m a) -> ContT m a +callcc f = KContT (\cont -> unKContT (f (\a -> KContT (\cont' -> cont a))) cont) + +{- +`ContT' is a continuation monad transformer. Note that we locally +qualify over the result type `res' (sometimes called answer or +output). IMHO this make it impossible to define control constructs +like `callcc'. Let's have a closer look: the code of `callcc' contains +the subexpression `KContT (\cont' -> cont a)'. To be well-typed the +argument of `KContT' must have the type `(All res) => (a -> m res) -> m +res'. Quantification is not possible, however, since the type variable +in `cont's type cannot be forall'd, since it also appears at an outer +level. Right? Or wrong? +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail076.stderr b/testsuite/tests/typecheck/should_fail/tcfail076.stderr new file mode 100644 index 0000000000..9c380de958 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail076.stderr @@ -0,0 +1,13 @@ + +tcfail076.hs:18:82: + Couldn't match type `res' with `res1' + `res' is a rigid type variable bound by + a type expected by the context: (a -> m res) -> m res + at tcfail076.hs:18:28 + `res1' is a rigid type variable bound by + a type expected by the context: (b -> m res1) -> m res1 + at tcfail076.hs:18:64 + Expected type: m res1 + Actual type: m res + In the return type of a call of `cont' + In the expression: cont a diff --git a/testsuite/tests/typecheck/should_fail/tcfail076.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail076.stderr-hugs new file mode 100644 index 0000000000..a4a05f09ba --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail076.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail076.hs":18 - Inferred type is not general enough +*** Expression : \cont' -> cont a +*** Expected type : (_29 -> _28 a) -> _28 a +*** Inferred type : (_29 -> _28 _30) -> _28 _30 diff --git a/testsuite/tests/typecheck/should_fail/tcfail077.hs b/testsuite/tests/typecheck/should_fail/tcfail077.hs new file mode 100644 index 0000000000..54735b98cd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail077.hs @@ -0,0 +1,8 @@ +module ShouldFail where + +-- !!! declaring a default method in a class that doesn't have that method. + +class Foo a where + op :: a -> a + + op2 x = x -- Bogus declaration diff --git a/testsuite/tests/typecheck/should_fail/tcfail077.stderr b/testsuite/tests/typecheck/should_fail/tcfail077.stderr new file mode 100644 index 0000000000..105604f66c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail077.stderr @@ -0,0 +1,2 @@ + +tcfail077.hs:8:3: `op2' is not a (visible) method of class `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail077.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail077.stderr-hugs new file mode 100644 index 0000000000..eb9afb0826 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail077.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail077.hs":8 - No member "op2" in class "Foo" diff --git a/testsuite/tests/typecheck/should_fail/tcfail078.hs b/testsuite/tests/typecheck/should_fail/tcfail078.hs new file mode 100644 index 0000000000..1054f6d3d6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail078.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- !!! Using a type constructor as a class name + +f :: Integer i => i +f = 0 diff --git a/testsuite/tests/typecheck/should_fail/tcfail078.stderr b/testsuite/tests/typecheck/should_fail/tcfail078.stderr new file mode 100644 index 0000000000..60636c94bf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail078.stderr @@ -0,0 +1,4 @@ +
+tcfail078.hs:5:6:
+ Type constructor `Integer' used as a class
+ In the type signature for `f': f :: Integer i => i
diff --git a/testsuite/tests/typecheck/should_fail/tcfail078.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail078.stderr-hugs new file mode 100644 index 0000000000..22a992258a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail078.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail078.hs":5 - Undefined class "Integer" diff --git a/testsuite/tests/typecheck/should_fail/tcfail079.hs b/testsuite/tests/typecheck/should_fail/tcfail079.hs new file mode 100644 index 0000000000..ec42260d69 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail079.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE MagicHash #-} + +module ShouldFail where + +-- !!! unboxed field in newtype declaration + +import GHC.Exts ( Int# ) + +newtype Unboxed = Unboxed Int# + +f = [ Unboxed 1#, Unboxed 2# ] -- shouldn't be allowed! diff --git a/testsuite/tests/typecheck/should_fail/tcfail079.stderr b/testsuite/tests/typecheck/should_fail/tcfail079.stderr new file mode 100644 index 0000000000..149f9b2171 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail079.stderr @@ -0,0 +1,7 @@ + +tcfail079.hs:9:27: + Expecting a lifted type, but `Int#' is unlifted + Expected kind `*', but `Int#' has kind `#' + In the type `Int#' + In the definition of data constructor `Unboxed' + In the newtype declaration for `Unboxed' diff --git a/testsuite/tests/typecheck/should_fail/tcfail080.hs b/testsuite/tests/typecheck/should_fail/tcfail080.hs new file mode 100644 index 0000000000..b2a62cea54 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail080.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +-- !!! Multi-param type classes test: ambiguity bug + +-- GHC actually accepts this program because +-- q :: Collection c a => a -> Bool +-- and there is no a priori reason to suppose that +-- q would be ambiguous in every context. For example, +-- it could be fine if we had +-- instance c Int where ... +-- Of course, it'd be hard to fill in the "..." in this particular +-- case, but that relies on observations about the form of the types +-- of the class methods, surely beyond what a compiler should do. +-- That's why GHC accepts it + +module ShouldFail where + +class Collection c a where + empty :: c a + add :: a -> c a -> c a + isempty :: c a -> Bool + +singleton x = add x empty + +q x = isempty (singleton x) + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail080.stderr b/testsuite/tests/typecheck/should_fail/tcfail080.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail080.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail080.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail080.stderr-hugs new file mode 100644 index 0000000000..790c9b97fa --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail080.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail080.hs":25 - Ambiguous type signature in inferred type +*** ambiguous type : Collection a b => b -> Bool +*** assigned to : q diff --git a/testsuite/tests/typecheck/should_fail/tcfail082.hs b/testsuite/tests/typecheck/should_fail/tcfail082.hs new file mode 100644 index 0000000000..2d4307acb1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail082.hs @@ -0,0 +1,9 @@ +module Main(main) where +import Data82 +import Inst82_1 +import Inst82_2 + +data Baz = Baz deriving Read + +main = print ((read "FooData")::FooData) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail082.stderr b/testsuite/tests/typecheck/should_fail/tcfail082.stderr new file mode 100644 index 0000000000..4fd34e6022 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail082.stderr @@ -0,0 +1,4 @@ + +tcfail082.hs:2:1: + Failed to load interface for `Data82' + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/typecheck/should_fail/tcfail082.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail082.stderr-hugs new file mode 100644 index 0000000000..028512324c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail082.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail082.hs" - Can't find imported module "Inst82_2" diff --git a/testsuite/tests/typecheck/should_fail/tcfail083.hs b/testsuite/tests/typecheck/should_fail/tcfail083.hs new file mode 100644 index 0000000000..a79be4e7ac --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail083.hs @@ -0,0 +1,16 @@ +module ShouldFail where + +data Bar = Bar { flag :: Bool } deriving( Show ) + +data State = State { bar :: Bar, baz :: Float } + +display :: State -> IO () +display (State{ bar = Bar { flag = f, baz = b }}) = print (f,b) + +-- Typo! The line above should better be: +-- display (State{ bar = Bar { flag = f }, baz = b }) = print (f,b) + +-- GHC 4.04 (as released) crashed with +-- panic! (the `impossible' happened): tcLookupValue: b{-r4n-} +-- Bug reported by Sven Panne + diff --git a/testsuite/tests/typecheck/should_fail/tcfail083.stderr b/testsuite/tests/typecheck/should_fail/tcfail083.stderr new file mode 100644 index 0000000000..77794ffaa6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail083.stderr @@ -0,0 +1,7 @@ + +tcfail083.hs:8:39: + Constructor `Bar' does not have field `baz' + In the pattern: Bar {flag = f, baz = b} + In the pattern: State {bar = Bar {flag = f, baz = b}} + In an equation for `display': + display (State {bar = Bar {flag = f, baz = b}}) = print (f, b) diff --git a/testsuite/tests/typecheck/should_fail/tcfail083.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail083.stderr-hugs new file mode 100644 index 0000000000..5535438428 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail083.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail083.hs":8 - No constructor has all of the fields specified in Bar {flag = f, baz = b} diff --git a/testsuite/tests/typecheck/should_fail/tcfail084.hs b/testsuite/tests/typecheck/should_fail/tcfail084.hs new file mode 100644 index 0000000000..22b5456b1e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail084.hs @@ -0,0 +1,11 @@ +-- !!! Check that using a label belonging to another constructor +-- !!! is flagged as being incorrect. +module ShouldFail where + +data F + = F { x :: Int } + | G { y :: Int } + +z :: F +z = F { y = 2 } + diff --git a/testsuite/tests/typecheck/should_fail/tcfail084.stderr b/testsuite/tests/typecheck/should_fail/tcfail084.stderr new file mode 100644 index 0000000000..1a7e8c3e28 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail084.stderr @@ -0,0 +1,5 @@ + +tcfail084.hs:10:5: + Constructor `F' does not have field `y' + In the expression: F {y = 2} + In an equation for `z': z = F {y = 2} diff --git a/testsuite/tests/typecheck/should_fail/tcfail084.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail084.stderr-hugs new file mode 100644 index 0000000000..2a9e60de1c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail084.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail084.hs":10 - Constructor "F" does not have selected fields in F {y = 2} diff --git a/testsuite/tests/typecheck/should_fail/tcfail085.hs b/testsuite/tests/typecheck/should_fail/tcfail085.hs new file mode 100644 index 0000000000..81036b9dfc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail085.hs @@ -0,0 +1,10 @@ +-- !!! Check that not supplying bindings for strict fields +-- !!! is flagged as being incorrect. +module ShouldFail where + +data F + = F { x :: Int, y :: !Int } + +z :: F +z = F { x = 2 } + diff --git a/testsuite/tests/typecheck/should_fail/tcfail085.stderr b/testsuite/tests/typecheck/should_fail/tcfail085.stderr new file mode 100644 index 0000000000..c500e7a180 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail085.stderr @@ -0,0 +1,5 @@ + +tcfail085.hs:9:5: + Constructor `F' does not have the required strict field(s): y + In the expression: F {x = 2} + In an equation for `z': z = F {x = 2} diff --git a/testsuite/tests/typecheck/should_fail/tcfail085.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail085.stderr-hugs new file mode 100644 index 0000000000..9f1bc068ca --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail085.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail085.hs":9 - Construction does not define strict field +Expression : F {x = 2} +Field : y diff --git a/testsuite/tests/typecheck/should_fail/tcfail086.hs b/testsuite/tests/typecheck/should_fail/tcfail086.hs new file mode 100644 index 0000000000..46d330daa6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail086.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- !!! Check that we can't derive instances of existential types +module ShouldFail where + +data Ex = forall a. Ex [a] deriving( Eq ) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail086.stderr b/testsuite/tests/typecheck/should_fail/tcfail086.stderr new file mode 100644 index 0000000000..4b221839ea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail086.stderr @@ -0,0 +1,6 @@ + +tcfail086.hs:6:38: + Can't make a derived instance of `Eq Ex': + Constructor `Ex' must have a Haskell-98 type + Possible fix: use a standalone deriving declaration instead + In the data type declaration for `Ex' diff --git a/testsuite/tests/typecheck/should_fail/tcfail086.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail086.stderr-hugs new file mode 100644 index 0000000000..4c3902b5b6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail086.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail086.hs":6 - Cannot derive instances for types with existentially typed components diff --git a/testsuite/tests/typecheck/should_fail/tcfail087.hs b/testsuite/tests/typecheck/should_fail/tcfail087.hs new file mode 100644 index 0000000000..6055a13d21 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail087.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE UnboxedTuples #-} + +-- !!! Check that unboxed tuples can't be function arguments +module ShouldFail where + +data Ex = Ex (# Int,Int #) + +f :: (# Int,Int #) -> Int +f x = error "urk" + +g (# x,y #) = x + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail087.stderr b/testsuite/tests/typecheck/should_fail/tcfail087.stderr new file mode 100644 index 0000000000..17d9f48537 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail087.stderr @@ -0,0 +1,5 @@ + +tcfail087.hs:6:11: + Illegal unboxed tuple type as function argument: (# Int, Int #) + In the definition of data constructor `Ex' + In the data type declaration for `Ex' diff --git a/testsuite/tests/typecheck/should_fail/tcfail088.hs b/testsuite/tests/typecheck/should_fail/tcfail088.hs new file mode 100644 index 0000000000..6b9f50751e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail088.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE Rank2Types, FlexibleInstances #-} + +-- !!! Check that forall types can't be arguments +module ShouldFail where + + +data T s a = MkT s a + +instance Ord a => Ord (forall s. T s a) +-- A for-all should not appear as an argument to Ord + + + +g :: T s (forall b.b) +g = error "urk" diff --git a/testsuite/tests/typecheck/should_fail/tcfail088.stderr b/testsuite/tests/typecheck/should_fail/tcfail088.stderr new file mode 100644 index 0000000000..1bf22ffaa8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail088.stderr @@ -0,0 +1,4 @@ + +tcfail088.hs:9:19: + Illegal polymorphic or qualified type: forall s. T s a + In the instance declaration for `Ord (forall s. T s a)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail088.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail088.stderr-hugs new file mode 100644 index 0000000000..e1b586a2e3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail088.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail088.hs":9 - Syntax error in type expression (unexpected keyword "forall") diff --git a/testsuite/tests/typecheck/should_fail/tcfail089.hs b/testsuite/tests/typecheck/should_fail/tcfail089.hs new file mode 100644 index 0000000000..142460b0f5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail089.hs @@ -0,0 +1,10 @@ + + +-- !!! Check non-constructors in patterns fail tidily +-- !!! The -O made ghc 4.08 go into a loop! +-- Unfortunately the -O has to go in the Makefile + +module ShouldFail where + +compute :: String -> String +compute ("hd" ++ _) = "_" diff --git a/testsuite/tests/typecheck/should_fail/tcfail089.stderr b/testsuite/tests/typecheck/should_fail/tcfail089.stderr new file mode 100644 index 0000000000..19dd837c13 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail089.stderr @@ -0,0 +1,2 @@ + +tcfail089.hs:10:10: Parse error in pattern: "hd" ++ _ diff --git a/testsuite/tests/typecheck/should_fail/tcfail089.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail089.stderr-hugs new file mode 100644 index 0000000000..c1152bc807 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail089.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail089.hs":10 - Syntax error in declaration (unexpected symbol "++") diff --git a/testsuite/tests/typecheck/should_fail/tcfail090.hs b/testsuite/tests/typecheck/should_fail/tcfail090.hs new file mode 100644 index 0000000000..93a9e9e925 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail090.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE MagicHash #-} + +module ShouldFail where + +import GHC.Base + +die :: Int -> ByteArray# +die _ = undefined diff --git a/testsuite/tests/typecheck/should_fail/tcfail090.stderr b/testsuite/tests/typecheck/should_fail/tcfail090.stderr new file mode 100644 index 0000000000..c63ced52c3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail090.stderr @@ -0,0 +1,7 @@ + +tcfail090.hs:8:9: + Kind incompatibility when matching types: + a0 :: * + ByteArray# :: # + In the expression: undefined + In an equation for `die': die _ = undefined diff --git a/testsuite/tests/typecheck/should_fail/tcfail091.hs b/testsuite/tests/typecheck/should_fail/tcfail091.hs new file mode 100644 index 0000000000..e64d1f512c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail091.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE ImplicitParams #-} + +-- !!! Illegal superclass constraint +-- These examples actually crashed GHC 4.08.2 + +module ShouldFail where + +class (?imp :: Int) => C t where + diff --git a/testsuite/tests/typecheck/should_fail/tcfail091.stderr b/testsuite/tests/typecheck/should_fail/tcfail091.stderr new file mode 100644 index 0000000000..74ca90b463 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail091.stderr @@ -0,0 +1,6 @@ + +tcfail091.hs:8:1: + Illegal constraint ?imp::Int + In the context: (?imp::Int) + While checking the super-classes of class `C' + In the class declaration for `C' diff --git a/testsuite/tests/typecheck/should_fail/tcfail091.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail091.stderr-hugs new file mode 100644 index 0000000000..f0a977936d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail091.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail091.hs":8 - Implicit parameters not permitted in class context diff --git a/testsuite/tests/typecheck/should_fail/tcfail092.hs b/testsuite/tests/typecheck/should_fail/tcfail092.hs new file mode 100644 index 0000000000..747f0ca3c7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail092.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE ParallelListComp #-} + +-- !!! Illegal conflicting parallel bindings + +module ShouldFail where + +xys = [ () | let a = 13 | let a = 17 ] diff --git a/testsuite/tests/typecheck/should_fail/tcfail092.stderr b/testsuite/tests/typecheck/should_fail/tcfail092.stderr new file mode 100644 index 0000000000..2ba048bb26 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail092.stderr @@ -0,0 +1,3 @@ + +tcfail092.hs:7:27: + Duplicate binding in parallel list comprehension for: `a' diff --git a/testsuite/tests/typecheck/should_fail/tcfail093.hs b/testsuite/tests/typecheck/should_fail/tcfail093.hs new file mode 100644 index 0000000000..9c2d8ea80a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail093.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + FlexibleInstances, UndecidableInstances #-} +-- UndecidableInstances now needed because the Coverage Condition fails + +module ShouldFail where + +-- A stripped down functional-dependency +-- example that causes GHC 4.08.1 to crash with: +-- "basicTypes/Var.lhs:194: Non-exhaustive patterns in function readMutTyVar" +-- Reported by Thomas Hallgren Nov 00 + +-- July 07: I'm changing this from "should fail" to "should succeed" +-- See Note [Important subtlety in oclose] in FunDeps + + +primDup :: Int -> IO Int +primDup = undefined + +dup () = call primDup + +-- call :: Call c h => c -> h +-- +-- call primDup :: {Call (Int -> IO Int) h} => h with +-- Using the instance decl gives +-- call primDup :: {Call (IO Int) h'} => Int -> h' +-- The functional dependency means that h must be constant +-- Hence program is rejected because it can't find an instance +-- for {Call (IO Int) h'} + +class Call c h | c -> h where + call :: c -> h + +instance Call c h => Call (Int->c) (Int->h) where + call f = call . f + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail094.hs b/testsuite/tests/typecheck/should_fail/tcfail094.hs new file mode 100644 index 0000000000..225ceb2d97 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail094.hs @@ -0,0 +1,10 @@ + + +module ShouldFail where + +-- This nonsense tickled a missing-kind-check error in ghc5.00.2 + +type A = Int 1 + + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail094.stderr b/testsuite/tests/typecheck/should_fail/tcfail094.stderr new file mode 100644 index 0000000000..8cd67b632b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail094.stderr @@ -0,0 +1,2 @@ + +tcfail094.hs:7:14: parse error on input `1' diff --git a/testsuite/tests/typecheck/should_fail/tcfail094.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail094.stderr-hugs new file mode 100644 index 0000000000..0d2e0206b2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail094.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail094.hs":7 - Syntax error in input (unexpected numeric literal) diff --git a/testsuite/tests/typecheck/should_fail/tcfail095.hs b/testsuite/tests/typecheck/should_fail/tcfail095.hs new file mode 100644 index 0000000000..b7cae9dbe5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail095.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE MagicHash #-} + +-- !!! Test top-level unboxed types + +module ShouldFail where + +import GHC.Base + +x = 1# diff --git a/testsuite/tests/typecheck/should_fail/tcfail095.stderr b/testsuite/tests/typecheck/should_fail/tcfail095.stderr new file mode 100644 index 0000000000..55f5b2954d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail095.stderr @@ -0,0 +1,3 @@ + +tcfail095.hs:9:1: + Top-level bindings for unlifted types aren't allowed: x = 1# diff --git a/testsuite/tests/typecheck/should_fail/tcfail096.hs b/testsuite/tests/typecheck/should_fail/tcfail096.hs new file mode 100644 index 0000000000..8a4edfbc6c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail096.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + FlexibleInstances #-} +module ShouldFail where + +class Foo f a r | f a -> r where + foo::f->a->r + +-- These instances are incompatible because we can unify +-- the first two paramters, though it's rather obscure: +-- p -> (a,b) +-- t -> (,) (a,a) +-- c -> (,) a +-- r -> s +-- +-- So a constraint which would sow this up is +-- Foo ((Int,Int)->Int) +-- ((Int,Int), (Int,Int)) +-- t +-- This matches both. Not easy to spot, and the error +-- message would be improved by giving the unifier, or +-- a witness. + +instance Foo (p->s) (t p) (t s) +instance Foo ((a,b)->r) (c a,c b)(c r) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail096.stderr b/testsuite/tests/typecheck/should_fail/tcfail096.stderr new file mode 100644 index 0000000000..c0ac91f6bf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail096.stderr @@ -0,0 +1,7 @@ + +tcfail096.hs:23:10: + Functional dependencies conflict between instance declarations: + instance Foo (p -> s) (t p) (t s) + -- Defined at tcfail096.hs:23:10-38 + instance Foo ((a, b) -> r) (c a, c b) (c r) + -- Defined at tcfail096.hs:24:10-38 diff --git a/testsuite/tests/typecheck/should_fail/tcfail096.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail096.stderr-hugs new file mode 100644 index 0000000000..7c3345bb51 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail096.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail096.hs":24 - Instances are not consistent with dependencies +*** This instance : Foo ((a,b) -> c) (d a,d b) (d c) +*** Conflicts with : Foo (a -> b) (c a) (c b) +*** For class : Foo a b c +*** Under dependency : a b -> c diff --git a/testsuite/tests/typecheck/should_fail/tcfail097.hs b/testsuite/tests/typecheck/should_fail/tcfail097.hs new file mode 100644 index 0000000000..4bcc798b98 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail097.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- !!! Ambiguous constraint in type signature + +f :: Eq a => Int -> Int +f x = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail097.stderr b/testsuite/tests/typecheck/should_fail/tcfail097.stderr new file mode 100644 index 0000000000..967b172bb9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail097.stderr @@ -0,0 +1,6 @@ +
+tcfail097.hs:5:1:
+ Ambiguous constraint `Eq a'
+ At least one of the forall'd type variables mentioned by the constraint
+ must be reachable from the type after the '=>'
+ In the type signature for `f': f :: Eq a => Int -> Int
diff --git a/testsuite/tests/typecheck/should_fail/tcfail097.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail097.stderr-hugs new file mode 100644 index 0000000000..9051289079 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail097.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail097.hs":5 - Ambiguous type signature in type declaration +*** ambiguous type : Eq a => Int -> Int +*** assigned to : f diff --git a/testsuite/tests/typecheck/should_fail/tcfail098.hs b/testsuite/tests/typecheck/should_fail/tcfail098.hs new file mode 100644 index 0000000000..2eab9e8f3b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail098.hs @@ -0,0 +1,9 @@ + +{-# LANGUAGE UndecidableInstances #-} + +module ShouldFail where + +-- !!! ambiguous constraint in the context of an instance declaration +class Bar a +instance Bar a => Bar Bool + diff --git a/testsuite/tests/typecheck/should_fail/tcfail098.stderr b/testsuite/tests/typecheck/should_fail/tcfail098.stderr new file mode 100644 index 0000000000..bf2ccabc30 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail098.stderr @@ -0,0 +1,6 @@ + +tcfail098.hs:8:10: + Ambiguous constraint `Bar a' + 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 `Bar Bool' diff --git a/testsuite/tests/typecheck/should_fail/tcfail098.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail098.stderr-hugs new file mode 100644 index 0000000000..9107dbbf06 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail098.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail098.hs":5 - Ambiguous type variable "a" diff --git a/testsuite/tests/typecheck/should_fail/tcfail099.hs b/testsuite/tests/typecheck/should_fail/tcfail099.hs new file mode 100644 index 0000000000..4cfa22c0f0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail099.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- This bogus program slipped past GHC 5.02! + +module ShouldFail where + +data DS = forall a. C (a -> Int) + +call (C f) arg = f arg diff --git a/testsuite/tests/typecheck/should_fail/tcfail099.stderr b/testsuite/tests/typecheck/should_fail/tcfail099.stderr new file mode 100644 index 0000000000..f97c5a1161 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail099.stderr @@ -0,0 +1,13 @@ + +tcfail099.hs:9:20: + Couldn't match type `t' with `a' + `t' is a rigid type variable bound by + the inferred type of call :: DS -> t -> Int at tcfail099.hs:9:1 + `a' is a rigid type variable bound by + a pattern with constructor + C :: forall a. (a -> Int) -> DS, + in an equation for `call' + at tcfail099.hs:9:7 + In the first argument of `f', namely `arg' + In the expression: f arg + In an equation for `call': call (C f) arg = f arg diff --git a/testsuite/tests/typecheck/should_fail/tcfail099.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail099.stderr-hugs new file mode 100644 index 0000000000..b36a4c519e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail099.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail099.hs":9 - Existentially quantified variable in inferred type +*** Variable : _6 +*** From pattern : C f +*** Result type : DS -> _6 -> Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail100.hs b/testsuite/tests/typecheck/should_fail/tcfail100.hs new file mode 100644 index 0000000000..1f125f3fda --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail100.hs @@ -0,0 +1,7 @@ +-- This one broke GHC 5.02, because of the unsaturated +-- uses of type synonyms, which are nevertheless kind-correct. + +module ShouldCompile where + +type A i = i +type B = A diff --git a/testsuite/tests/typecheck/should_fail/tcfail100.stderr b/testsuite/tests/typecheck/should_fail/tcfail100.stderr new file mode 100644 index 0000000000..36ee6f8218 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail100.stderr @@ -0,0 +1,4 @@ + +tcfail100.hs:7:1: + Type synonym `A' should have 1 argument, but has been given none + In the type synonym declaration for `B' diff --git a/testsuite/tests/typecheck/should_fail/tcfail100.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail100.stderr-hugs new file mode 100644 index 0000000000..b4aa433ae9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail100.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail100.hs":7 - Not enough arguments for type synonym "A" diff --git a/testsuite/tests/typecheck/should_fail/tcfail101.hs b/testsuite/tests/typecheck/should_fail/tcfail101.hs new file mode 100644 index 0000000000..8bd88749c3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail101.hs @@ -0,0 +1,10 @@ +-- This one broke GHC 5.02, because of the unsaturated +-- uses of type synonyms, which are nevertheless kind-correct. + +module ShouldCompile where + +type A i = i +data T k = MkT (k Int) + +f :: T A -- BAD! +f = error "foo" diff --git a/testsuite/tests/typecheck/should_fail/tcfail101.stderr b/testsuite/tests/typecheck/should_fail/tcfail101.stderr new file mode 100644 index 0000000000..0d82b50750 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail101.stderr @@ -0,0 +1,4 @@ + +tcfail101.hs:9:1: + Type synonym `A' should have 1 argument, but has been given none + In the type signature for `f': f :: T A diff --git a/testsuite/tests/typecheck/should_fail/tcfail101.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail101.stderr-hugs new file mode 100644 index 0000000000..626664525d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail101.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail101.hs":9 - Not enough arguments for type synonym "A" diff --git a/testsuite/tests/typecheck/should_fail/tcfail102.hs b/testsuite/tests/typecheck/should_fail/tcfail102.hs new file mode 100644 index 0000000000..f4941789ff --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail102.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE DatatypeContexts #-} +module ShouldFail where + +import Data.Ratio + +data Integral a => P a = P { p :: a } + +f :: Integral a => P (Ratio a) -> P (Ratio a) +f x = x { p = p x } diff --git a/testsuite/tests/typecheck/should_fail/tcfail102.stderr b/testsuite/tests/typecheck/should_fail/tcfail102.stderr new file mode 100644 index 0000000000..af047e5dce --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail102.stderr @@ -0,0 +1,17 @@ + +tcfail102.hs:1:14: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail102.hs:9:7: + Could not deduce (Integral (Ratio a)) arising from a record update + from the context (Integral a) + bound by the type signature for + f :: Integral a => P (Ratio a) -> P (Ratio a) + at tcfail102.hs:9:1-19 + Possible fix: + add (Integral (Ratio a)) to the context of + the type signature for + f :: Integral a => P (Ratio a) -> P (Ratio a) + or add an instance declaration for (Integral (Ratio a)) + In the expression: x {p = p x} + In an equation for `f': f x = x {p = p x} diff --git a/testsuite/tests/typecheck/should_fail/tcfail102.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail102.stderr-hugs new file mode 100644 index 0000000000..7584fda32e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail102.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail102.hs":8 - Cannot justify constraints in explicitly typed binding +*** Expression : f +*** Type : Integral a => P (Ratio a) -> P (Ratio a) +*** Given context : Integral a +*** Constraints : Integral (Ratio a) diff --git a/testsuite/tests/typecheck/should_fail/tcfail103.hs b/testsuite/tests/typecheck/should_fail/tcfail103.hs new file mode 100644 index 0000000000..2ed6df2485 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail103.hs @@ -0,0 +1,16 @@ + + +module ShouldCompile where +import GHC.ST +import GHC.STRef +import GHC.Arr + +-- Another 'escape' example + +f:: ST t Int +f = do + v <- newSTRef 5 + let g :: ST s Int + -- Implicitly forall s. ST s Int + g = readSTRef v + g diff --git a/testsuite/tests/typecheck/should_fail/tcfail103.stderr b/testsuite/tests/typecheck/should_fail/tcfail103.stderr new file mode 100644 index 0000000000..636ab29ae7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail103.stderr @@ -0,0 +1,11 @@ + +tcfail103.hs:15:23: + Couldn't match type `t' with `s' + `t' is a rigid type variable bound by + the type signature for f :: ST t Int at tcfail103.hs:11:1 + `s' is a rigid type variable bound by + the type signature for g :: ST s Int at tcfail103.hs:15:9 + Expected type: STRef s Int + Actual type: STRef t Int + In the first argument of `readSTRef', namely `v' + In the expression: readSTRef v diff --git a/testsuite/tests/typecheck/should_fail/tcfail104.hs b/testsuite/tests/typecheck/should_fail/tcfail104.hs new file mode 100644 index 0000000000..292780541c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail104.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE Rank2Types, ScopedTypeVariables #-} + +-- Test the handling of conditionals in rank-n stuff +-- Should fail, regardless of branch ordering + +module ShouldFail where + +-- These two are ok +f1 = (\ (x :: forall a. a->a) -> x) +f2 = (\ (x :: forall a. a->a) -> x) id 'c' + +-- These fail +f3 v = (if v then + (\ (x :: forall a. a->a) -> x) + else + (\ x -> x) + ) id 'c' + +f4 v = (if v then + (\ x -> x) + else + (\ (x :: forall a. a->a) -> x) + ) id 'c' diff --git a/testsuite/tests/typecheck/should_fail/tcfail104.stderr b/testsuite/tests/typecheck/should_fail/tcfail104.stderr new file mode 100644 index 0000000000..8bd4608bde --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail104.stderr @@ -0,0 +1,16 @@ + +tcfail104.hs:16:19: + Couldn't match expected type `a0 -> a0' + with actual type `forall a. a -> a' + In the expression: x + In the expression: (\ x -> x) + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + +tcfail104.hs:22:39: + Couldn't match expected type `forall a. a -> a' + with actual type `a0 -> a0' + In the expression: x + In the expression: (\ (x :: forall a. a -> a) -> x) + In the expression: + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) diff --git a/testsuite/tests/typecheck/should_fail/tcfail105.hs b/testsuite/tests/typecheck/should_fail/tcfail105.hs new file mode 100644 index 0000000000..331e38322b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail105.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- Existential context should quantify over some new type variables +-- +-- Jan07: this is now fine, because we've lifted the restrction +-- that the context on a constructor should mention +-- existential type variables + +module ShouldFail where + +data S m t a = Ok a | Cont (M m t a) +data M m t a = Monad m => M { unM::(m (S m t a))} + diff --git a/testsuite/tests/typecheck/should_fail/tcfail105.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail105.stderr-hugs new file mode 100644 index 0000000000..16bedfe8b9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail105.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail105.hs":8 - Syntax error in input (unexpected `=>') diff --git a/testsuite/tests/typecheck/should_fail/tcfail106.hs b/testsuite/tests/typecheck/should_fail/tcfail106.hs new file mode 100644 index 0000000000..22c732e4ce --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail106.hs @@ -0,0 +1,15 @@ +-- This one risked building a recursive dictionary rather than +-- failing, in GHC before 5.03. Actually, 5.02 managed it ok, +-- but I think more by luck than good judgement. + +module ShouldFail where + +class S a +class S a => C a where { opc :: a -> a } +class S b => D b where { opd :: b -> b } + +instance C Int where + opc = opd + +instance D Int where + opd = opc diff --git a/testsuite/tests/typecheck/should_fail/tcfail106.stderr b/testsuite/tests/typecheck/should_fail/tcfail106.stderr new file mode 100644 index 0000000000..e9de772233 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail106.stderr @@ -0,0 +1,12 @@ + +tcfail106.hs:11:10: + No instance for (S Int) + arising from the superclasses of an instance declaration + Possible fix: add an instance declaration for (S Int) + In the instance declaration for `C Int' + +tcfail106.hs:14:10: + No instance for (S Int) + arising from the superclasses of an instance declaration + Possible fix: add an instance declaration for (S Int) + In the instance declaration for `D Int' diff --git a/testsuite/tests/typecheck/should_fail/tcfail106.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail106.stderr-hugs new file mode 100644 index 0000000000..6574cc7864 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail106.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail106.hs":11 - Cannot build superclass instance +*** Instance : C Int +*** Context supplied : () +*** Required superclass : S Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail107.hs b/testsuite/tests/typecheck/should_fail/tcfail107.hs new file mode 100644 index 0000000000..e612e65093 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail107.hs @@ -0,0 +1,14 @@ +-- The type sig for 'test' is illegal in H98 because of the +-- partial application of the type sig. +-- But with the LiberalTypeSynonyms extension enabled it +-- should be OK because when you expand the type synonyms +-- it's just Int->Int +-- c.f should_compile/tc155.hs +module ShouldFail where + +type Thing m = m () + +type Const a b = a + +test :: Thing (Const Int) -> Thing (Const Int) +test = test diff --git a/testsuite/tests/typecheck/should_fail/tcfail107.stderr b/testsuite/tests/typecheck/should_fail/tcfail107.stderr new file mode 100644 index 0000000000..eae3610c1d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail107.stderr @@ -0,0 +1,5 @@ + +tcfail107.hs:13:1: + Type synonym `Const' should have 2 arguments, but has been given 1 + In the type signature for `test': + test :: Thing (Const Int) -> Thing (Const Int) diff --git a/testsuite/tests/typecheck/should_fail/tcfail107.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail107.stderr-hugs new file mode 100644 index 0000000000..6c08b363b5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail107.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail107.hs":13 - Not enough arguments for type synonym "Const" diff --git a/testsuite/tests/typecheck/should_fail/tcfail108.hs b/testsuite/tests/typecheck/should_fail/tcfail108.hs new file mode 100644 index 0000000000..5ccebde83e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail108.hs @@ -0,0 +1,9 @@ +-- The instance decl is illegal without UndecidableInstances + +module ShouldFail where + +data Rec f = In (f (Rec f)) + +instance Eq (f (Rec f)) => Eq (Rec f) where + (In x) == (In y) = x == y + diff --git a/testsuite/tests/typecheck/should_fail/tcfail108.stderr b/testsuite/tests/typecheck/should_fail/tcfail108.stderr new file mode 100644 index 0000000000..5d406cd5a6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail108.stderr @@ -0,0 +1,7 @@ + +tcfail108.hs:7:10: + Non type-variable argument in the constraint: Eq (f (Rec f)) + (Use -XFlexibleContexts to permit this) + In the context: (Eq (f (Rec f))) + While checking the context of an instance declaration + In the instance declaration for `Eq (Rec f)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail108.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail108.stderr-hugs new file mode 100644 index 0000000000..f5011fddc7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail108.stderr-hugs @@ -0,0 +1,2 @@ +ERROR "tcfail108.hs":7 - Illegal Haskell 98 class constraint in instance declaration +*** Constraint : Eq (a (Rec a)) diff --git a/testsuite/tests/typecheck/should_fail/tcfail109.hs b/testsuite/tests/typecheck/should_fail/tcfail109.hs new file mode 100644 index 0000000000..861183a399 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail109.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} + +-- Strangely, this program does not elicit an error message +-- in GHC 5.03. I don't know why. It fails correctly in +-- 5.04 + + +module ShouldFail where + +class Eq ce => Collects e ce | ce -> e where + empty :: ce + empty = error("empty") + +data Stupid = Stupid -- without equality + +instance Collects Bool Stupid where diff --git a/testsuite/tests/typecheck/should_fail/tcfail109.stderr b/testsuite/tests/typecheck/should_fail/tcfail109.stderr new file mode 100644 index 0000000000..a72c6238d9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail109.stderr @@ -0,0 +1,6 @@ + +tcfail109.hs:16:10: + No instance for (Eq Stupid) + arising from the superclasses of an instance declaration + Possible fix: add an instance declaration for (Eq Stupid) + In the instance declaration for `Collects Bool Stupid' diff --git a/testsuite/tests/typecheck/should_fail/tcfail109.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail109.stderr-hugs new file mode 100644 index 0000000000..3a7abb8842 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail109.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail109.hs":16 - Cannot build superclass instance +*** Instance : Collects Bool Stupid +*** Context supplied : () +*** Required superclass : Eq Stupid diff --git a/testsuite/tests/typecheck/should_fail/tcfail110.hs b/testsuite/tests/typecheck/should_fail/tcfail110.hs new file mode 100644 index 0000000000..92aeb56c06 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail110.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE Rank2Types #-} + +module ShouldCompile where + +data Foo a b = Foo { foo :: a -> b } + +-- kind error in here +bar :: String -> (forall a . Foo a) -> IO () +bar s _ = putStrLn s diff --git a/testsuite/tests/typecheck/should_fail/tcfail110.stderr b/testsuite/tests/typecheck/should_fail/tcfail110.stderr new file mode 100644 index 0000000000..e663999edb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail110.stderr @@ -0,0 +1,6 @@ + +tcfail110.hs:8:30: + `Foo a' is not applied to enough type arguments + Expected kind `*', but `Foo a' has kind `* -> *' + In the type signature for `bar': + bar :: String -> (forall a. Foo a) -> IO () diff --git a/testsuite/tests/typecheck/should_fail/tcfail110.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail110.stderr-hugs new file mode 100644 index 0000000000..4cc90e0a43 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail110.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail110.hs":8 - Illegal type in polymorphic type diff --git a/testsuite/tests/typecheck/should_fail/tcfail111.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail111.stderr-hugs new file mode 100644 index 0000000000..46e9b8d08e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail111.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail111.hs":7 - Ambiguous type variable "a" diff --git a/testsuite/tests/typecheck/should_fail/tcfail112.hs b/testsuite/tests/typecheck/should_fail/tcfail112.hs new file mode 100644 index 0000000000..01dd578ab7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail112.hs @@ -0,0 +1,15 @@ +-- Record construction should fail statically +-- if there are any strict fields, +-- including in the non-record case. + +module ShouldFail where + +data S = S { x::Int, y:: ! Int } +data T = T Int !Int +data U = U Int Int + +s1 = S {} -- Bad +s2 = S { x=3 } -- Bad +s3 = S { y=3 } -- Ok +t = T {} -- Bad +u = U {} -- Ok diff --git a/testsuite/tests/typecheck/should_fail/tcfail112.stderr b/testsuite/tests/typecheck/should_fail/tcfail112.stderr new file mode 100644 index 0000000000..602c1e4b69 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail112.stderr @@ -0,0 +1,15 @@ + +tcfail112.hs:11:6: + Constructor `S' does not have the required strict field(s): y + In the expression: S {} + In an equation for `s1': s1 = S {} + +tcfail112.hs:12:6: + Constructor `S' does not have the required strict field(s): y + In the expression: S {x = 3} + In an equation for `s2': s2 = S {x = 3} + +tcfail112.hs:14:6: + Constructor `T' does not have the required strict field(s) + In the expression: T {} + In an equation for `t': t = T {} diff --git a/testsuite/tests/typecheck/should_fail/tcfail112.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail112.stderr-hugs new file mode 100644 index 0000000000..3b64822662 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail112.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail112.hs":11 - Construction does not define strict field +Expression : S {} +Field : y diff --git a/testsuite/tests/typecheck/should_fail/tcfail113.hs b/testsuite/tests/typecheck/should_fail/tcfail113.hs new file mode 100644 index 0000000000..1628cd7c41 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail113.hs @@ -0,0 +1,19 @@ +-- Tests kind error messages + +-- GHC 6.6 stops on the first kind error it encounters, +-- so we only get one error report here. I'll leave +-- the other tests in here, though, in case matters improve +-- again + +module ShouldFail where + +data T k = T (k Int) + +f :: [Maybe] +f x = x + +g :: T Int +g x = x + +h :: Int Int +h x = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail113.stderr b/testsuite/tests/typecheck/should_fail/tcfail113.stderr new file mode 100644 index 0000000000..d4c9208243 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail113.stderr @@ -0,0 +1,18 @@ + +tcfail113.hs:12:7: + `Maybe' is not applied to enough type arguments + Expected kind `*', but `Maybe' has kind `* -> *' + In the type signature for `f': + f :: [Maybe] + +tcfail113.hs:15:8: + Kind mis-match + The first argument of `T' should have kind `* -> *', + but `Int' has kind `*' + In the type signature for `g': + g :: T Int + +tcfail113.hs:18:6: + `Int' is applied to too many type arguments + In the type signature for `h': + h :: Int Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail113.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail113.stderr-hugs new file mode 100644 index 0000000000..014006a69a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail113.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail113.hs":7 - Illegal type "[Maybe]" in constructor application diff --git a/testsuite/tests/typecheck/should_fail/tcfail114.hs b/testsuite/tests/typecheck/should_fail/tcfail114.hs new file mode 100644 index 0000000000..2d0fc19f4b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail114.hs @@ -0,0 +1,13 @@ +-- Killed GHC 5.04.2 + +module ShouldFail where + +class Foo a where + foo :: a -> () + +data Bar = Bar { bar :: () } + +test :: Bar +test = undefined { foo = () } + -- The point is that foo is a class method, + -- but not a record selector diff --git a/testsuite/tests/typecheck/should_fail/tcfail114.stderr b/testsuite/tests/typecheck/should_fail/tcfail114.stderr new file mode 100644 index 0000000000..601feff85b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail114.stderr @@ -0,0 +1,5 @@ + +tcfail114.hs:11:20: + `foo' is not a record selector + In the expression: undefined {foo = ()} + In an equation for `test': test = undefined {foo = ()} diff --git a/testsuite/tests/typecheck/should_fail/tcfail114.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail114.stderr-hugs new file mode 100644 index 0000000000..3a7663b166 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail114.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail114.hs":11 - "foo" is not a selector function/field name diff --git a/testsuite/tests/typecheck/should_fail/tcfail115.hs b/testsuite/tests/typecheck/should_fail/tcfail115.hs new file mode 100644 index 0000000000..971f625a9a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail115.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE UnboxedTuples #-} + +-- Unboxed tuples; c.f. tcfail120, tc209 + +module ShouldFail where + +type T a = Int -> (# Int, Int #) + +g t = case t of r -> (r :: (# Int, Int #)) + +f :: T a -> T a +f t = \x -> case t x of r -> r + diff --git a/testsuite/tests/typecheck/should_fail/tcfail115.stderr b/testsuite/tests/typecheck/should_fail/tcfail115.stderr new file mode 100644 index 0000000000..fd1a02c02d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail115.stderr @@ -0,0 +1,14 @@ + +tcfail115.hs:9:24: + Kind incompatibility when matching types: + t0 :: ?? + (# Int, Int #) :: (#) + In the expression: (r :: (# Int, Int #)) + In a case alternative: r -> (r :: (# Int, Int #)) + In the expression: case t of { r -> (r :: (# Int, Int #)) } + +tcfail115.hs:12:25: + The variable `r' cannot have an unboxed tuple type: (# Int, Int #) + In a case alternative: r -> r + In the expression: case t x of { r -> r } + In the expression: \ x -> case t x of { r -> r } diff --git a/testsuite/tests/typecheck/should_fail/tcfail116.hs b/testsuite/tests/typecheck/should_fail/tcfail116.hs new file mode 100644 index 0000000000..1c32c956d3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail116.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- in Haskell 98, methods must mention the class variable +-- (SourceForge bug #756454). +class Foo a where + bug :: () diff --git a/testsuite/tests/typecheck/should_fail/tcfail116.stderr b/testsuite/tests/typecheck/should_fail/tcfail116.stderr new file mode 100644 index 0000000000..8e7372413a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail116.stderr @@ -0,0 +1,6 @@ + +tcfail116.hs:5:1: + The class method `bug' + mentions none of the type variables of the class Foo a + When checking the class method: bug :: () + In the class declaration for `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail116.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail116.stderr-hugs new file mode 100644 index 0000000000..fba5f2db38 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail116.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail116.hs":6 - Ambiguous type signature in class declaration +*** ambiguous type : Foo a => () +*** assigned to : bug diff --git a/testsuite/tests/typecheck/should_fail/tcfail117.hs b/testsuite/tests/typecheck/should_fail/tcfail117.hs new file mode 100644 index 0000000000..2a5ae99172 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail117.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- Without any extensions enabled both of these should fail + +newtype N1 = N1 Int deriving ( Enum ) +data N2 = N2 Int deriving ( Enum ) diff --git a/testsuite/tests/typecheck/should_fail/tcfail117.stderr b/testsuite/tests/typecheck/should_fail/tcfail117.stderr new file mode 100644 index 0000000000..2bc3d7fd63 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail117.stderr @@ -0,0 +1,13 @@ + +tcfail117.hs:5:32: + Can't make a derived instance of `Enum N1': + `N1' must be an enumeration type + (an enumeration consists of one or more nullary, non-GADT constructors) + Try -XGeneralizedNewtypeDeriving for GHC's newtype-deriving extension + In the newtype declaration for `N1' + +tcfail117.hs:6:32: + Can't make a derived instance of `Enum N2': + `N2' must be an enumeration type + (an enumeration consists of one or more nullary, non-GADT constructors) + In the data type declaration for `N2' diff --git a/testsuite/tests/typecheck/should_fail/tcfail117.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail117.stderr-hugs new file mode 100644 index 0000000000..b6db2d800a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail117.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail117.hs":5 - Can only derive instances of Enum for enumeration types diff --git a/testsuite/tests/typecheck/should_fail/tcfail118.hs b/testsuite/tests/typecheck/should_fail/tcfail118.hs new file mode 100644 index 0000000000..1b81c7e01a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail118.hs @@ -0,0 +1,15 @@ +-- Gave a bad error message in a version of 6.3, as a +-- result of 6.3's new duplicate-instance reporting structure +-- +-- Foo.hs:4:5: +-- No instance for `Eq Foo' +-- When deriving the `Eq' instance for type `Bar' + +module ShouldFail where + +data Bar = Bar Foo deriving Eq +data Foo = Foo deriving Eq + +instance Eq Foo where + Foo == Foo = True + diff --git a/testsuite/tests/typecheck/should_fail/tcfail118.stderr b/testsuite/tests/typecheck/should_fail/tcfail118.stderr new file mode 100644 index 0000000000..206bec47be --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail118.stderr @@ -0,0 +1,8 @@ + +tcfail118.hs:10:29: + Overlapping instances for Eq Foo + arising from the 'deriving' clause of a data type declaration + Matching instances: + instance Eq Foo -- Defined at tcfail118.hs:11:25-26 + instance Eq Foo -- Defined at tcfail118.hs:13:10-15 + When deriving the instance for (Eq Bar) diff --git a/testsuite/tests/typecheck/should_fail/tcfail118.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail118.stderr-hugs new file mode 100644 index 0000000000..691a20ee0a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail118.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail118.hs":11 - Overlapping instances for class "Eq" +*** This instance : Eq Foo +*** Overlaps with : Eq Foo +*** Common instance : Eq Foo diff --git a/testsuite/tests/typecheck/should_fail/tcfail119.hs b/testsuite/tests/typecheck/should_fail/tcfail119.hs new file mode 100644 index 0000000000..52b9c8a5eb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail119.hs @@ -0,0 +1,14 @@ +-- Gave a nasty +-- tcLookupGlobal: `FunnyError.$dmb' is not in scope +-- failure in GHC 6.2, because the type-checking of +-- the default method didn't recover. + +module ShouldFail where + +class A x where + a :: x -> () + b :: x -> Bool -> () + b x "Foo" = () -- deliberate type error + +instance A Int where + a _ = () diff --git a/testsuite/tests/typecheck/should_fail/tcfail119.stderr b/testsuite/tests/typecheck/should_fail/tcfail119.stderr new file mode 100644 index 0000000000..1984617b2b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail119.stderr @@ -0,0 +1,5 @@ + +tcfail119.hs:11:8: + Couldn't match expected type `Bool' with actual type `[Char]' + In the pattern: "Foo" + In an equation for `b': b x "Foo" = () diff --git a/testsuite/tests/typecheck/should_fail/tcfail119.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail119.stderr-hugs new file mode 100644 index 0000000000..443f073bcd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail119.stderr-hugs @@ -0,0 +1,4 @@ +ERROR "tcfail119.hs":11 - Type error in default member binding +*** Term : "Foo" +*** Type : String +*** Does not match : Bool diff --git a/testsuite/tests/typecheck/should_fail/tcfail120.hs b/testsuite/tests/typecheck/should_fail/tcfail120.hs new file mode 100644 index 0000000000..04b7cd60ab --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail120.hs @@ -0,0 +1,14 @@ + +{-# LANGUAGE UnboxedTuples #-} + +-- Could be ok, because nothing is bound to the unboxed tuple +-- but actually rejected, because a wild card is rather like +-- an unused variable. Could fix this, but it's really a corner case + +module ShouldFail where + +type T a = Int -> (# Int, Int #) + +f2 :: T a -> T a +f2 t = \x -> case t x of _ -> (# 3,4 #) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail120.stderr b/testsuite/tests/typecheck/should_fail/tcfail120.stderr new file mode 100644 index 0000000000..7693b0c7c5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail120.stderr @@ -0,0 +1,7 @@ + +tcfail120.hs:13:26: + A wild-card pattern cannot have an unboxed tuple type: + (# Int, Int #) + In the pattern: _ + In a case alternative: _ -> (# 3, 4 #) + In the expression: case t x of { _ -> (# 3, 4 #) } diff --git a/testsuite/tests/typecheck/should_fail/tcfail121.hs b/testsuite/tests/typecheck/should_fail/tcfail121.hs new file mode 100644 index 0000000000..86c2a92c5c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail121.hs @@ -0,0 +1,14 @@ + +{-# LANGUAGE OverlappingInstances, FlexibleInstances #-} + +module ShouldFail where + +class Foo a where + op :: a -> a + +instance Foo a => Foo [a] +instance Foo [Int] + +foo :: Foo a => [a] -> [a] +foo x = op x +-- Correct instance depends on instantiation of 'a' diff --git a/testsuite/tests/typecheck/should_fail/tcfail121.stderr b/testsuite/tests/typecheck/should_fail/tcfail121.stderr new file mode 100644 index 0000000000..783331fdfc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail121.stderr @@ -0,0 +1,13 @@ + +tcfail121.hs:13:9: + Overlapping instances for Foo [a] + arising from a use of `op' + Matching instances: + instance [overlap ok] Foo a => Foo [a] + -- Defined at tcfail121.hs:9:10-25 + instance [overlap ok] Foo [Int] -- Defined at tcfail121.hs:10:10-18 + (The choice depends on the instantiation of `a' + To pick the first instance above, use -XIncoherentInstances + when compiling the other instance declarations) + In the expression: op x + In an equation for `foo': foo x = op x diff --git a/testsuite/tests/typecheck/should_fail/tcfail122.hs b/testsuite/tests/typecheck/should_fail/tcfail122.hs new file mode 100644 index 0000000000..ae2bef8bea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail122.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE Rank2Types, KindSignatures #-} + +module ShouldFail where + +-- There should be a kind error, when unifying (a b) against (c d) + +foo = [ undefined :: forall a b. a b, + undefined :: forall (c:: (* -> *) -> *) (d :: * -> *). c d ] diff --git a/testsuite/tests/typecheck/should_fail/tcfail122.stderr b/testsuite/tests/typecheck/should_fail/tcfail122.stderr new file mode 100644 index 0000000000..3f6c035a55 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail122.stderr @@ -0,0 +1,26 @@ + +tcfail122.hs:8:9: + Kind incompatibility when matching types: + d0 :: * -> * + b0 :: * + Expected type: a0 b0 + Actual type: c0 d0 + In the expression: + undefined :: forall c :: ((* -> *) -> *) d :: (* -> *). c d + In the expression: + [undefined :: forall a b. a b, + undefined :: forall c :: ((* -> *) -> *) d :: (* -> *). c d] + +tcfail122.hs:8:9: + Kind incompatibility when matching types: + c0 :: (* -> *) -> * + a0 :: * -> * + In the expression: + undefined :: forall c :: ((* -> *) -> *) d :: (* -> *). c d + In the expression: + [undefined :: forall a b. a b, + undefined :: forall c :: ((* -> *) -> *) d :: (* -> *). c d] + In an equation for `foo': + foo + = [undefined :: forall a b. a b, + undefined :: forall c :: ((* -> *) -> *) d :: (* -> *). c d] diff --git a/testsuite/tests/typecheck/should_fail/tcfail123.hs b/testsuite/tests/typecheck/should_fail/tcfail123.hs new file mode 100644 index 0000000000..8e91bbe885 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail123.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE MagicHash #-} + +module ShouldFail where + +-- The danger here is getting a type like +-- f :: forall (a::??). a -> Bool +-- and hence allowing the bogus calls that follow + +f x = True + +h v = (f 3#, f 4.3#, f True) diff --git a/testsuite/tests/typecheck/should_fail/tcfail123.stderr b/testsuite/tests/typecheck/should_fail/tcfail123.stderr new file mode 100644 index 0000000000..560c8d9048 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail123.stderr @@ -0,0 +1,16 @@ + +tcfail123.hs:11:10: + Kind incompatibility when matching types: + t0 :: * + GHC.Prim.Int# :: # + In the first argument of `f', namely `3#' + In the expression: f 3# + In the expression: (f 3#, f 4.3#, f True) + +tcfail123.hs:11:16: + Kind incompatibility when matching types: + t1 :: * + GHC.Prim.Float# :: # + In the first argument of `f', namely `4.3#' + In the expression: f 4.3# + In the expression: (f 3#, f 4.3#, f True) diff --git a/testsuite/tests/typecheck/should_fail/tcfail124.hs b/testsuite/tests/typecheck/should_fail/tcfail124.hs new file mode 100644 index 0000000000..729d14b601 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail124.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module ShouldFail where + +-- With the new typechecker (GHC 7.1), these now all pass + +f1 :: (forall a. Eq a => [a]) -> Bool +f1 xs@(x:_) = x + +f2 :: (forall a. Eq a => [a]) -> Bool +f2 [x] = x + +f3 :: (forall a. Eq a => [a]) -> Bool +f3 (x:[]) = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail124.stderr b/testsuite/tests/typecheck/should_fail/tcfail124.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail124.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail125.hs b/testsuite/tests/typecheck/should_fail/tcfail125.hs new file mode 100644 index 0000000000..664354d840 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail125.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE DatatypeContexts, ExistentialQuantification #-} + +-- Tests the "stupid theta" in pattern-matching +-- when there's an existential as well + +module ShouldCompile where + +data (Show a) => Obs a = forall b. LiftObs a b + +f :: Obs a -> String -- Needs a (Show a) context +f (LiftObs _ _) = "yes" diff --git a/testsuite/tests/typecheck/should_fail/tcfail125.stderr b/testsuite/tests/typecheck/should_fail/tcfail125.stderr new file mode 100644 index 0000000000..988540dad5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail125.stderr @@ -0,0 +1,9 @@ + +tcfail125.hs:1:14: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail125.hs:11:4: + No instance for (Show a) + arising from a use of `LiftObs' + In the pattern: LiftObs _ _ + In an equation for `f': f (LiftObs _ _) = "yes" diff --git a/testsuite/tests/typecheck/should_fail/tcfail125.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail125.stderr-hugs new file mode 100644 index 0000000000..7fc582ba2d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail125.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail125.hs":11 - Cannot justify constraints in explicitly typed binding +*** Expression : f +*** Type : Obs a -> String +*** Given context : () +*** Constraints : Show a diff --git a/testsuite/tests/typecheck/should_fail/tcfail126.hs b/testsuite/tests/typecheck/should_fail/tcfail126.hs new file mode 100644 index 0000000000..1ef2b4820e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail126.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE RankNTypes, ExistentialQuantification #-} + +-- An interesting interaction of universals and existentials, prompted by +-- http://www.haskell.org/pipermail/haskell-cafe/2004-October/007160.html +-- +-- Note the nested pattern-match in runProg; tc183 checks the +-- non-nested version + +-- 3 Sept 2010: with the new typechecker, this one succeeds + +module Foo where + +import Control.Monad.Trans + +data Bar m + = forall t. (MonadTrans t, Monad (t m)) + => Bar (t m () -> m ()) (t m Int) + +data Foo = Foo (forall m. Monad m => Bar m) + +runProg :: Foo -> IO () +runProg (Foo (Bar run op)) = run (prog op) +-- This nested match "ought" to work; because +-- runProg (Foo b) = case b of +-- Bar run op -> run (prog op) +-- does work. But the interactions with GADTs and +-- desugaring defeated me, and I removed (in GHC 6.4) the ability +-- to instantiate functions on the left + +prog :: (MonadTrans t, Monad (t IO)) => a -> t IO () +prog x = error "urk" diff --git a/testsuite/tests/typecheck/should_fail/tcfail126.stderr b/testsuite/tests/typecheck/should_fail/tcfail126.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail126.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail127.hs b/testsuite/tests/typecheck/should_fail/tcfail127.hs new file mode 100644 index 0000000000..32b9e37de5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail127.hs @@ -0,0 +1,7 @@ +module ShouldFail where + +foo :: IO (Num a => a -> a) +foo = error "urk" + +-- baz :: (Num a => a -> a) -> Int +-- baz = error "urk" diff --git a/testsuite/tests/typecheck/should_fail/tcfail127.stderr b/testsuite/tests/typecheck/should_fail/tcfail127.stderr new file mode 100644 index 0000000000..8fa64fb204 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail127.stderr @@ -0,0 +1,5 @@ +
+tcfail127.hs:3:1:
+ Illegal polymorphic or qualified type: Num a => a -> a
+ Perhaps you intended to use -XImpredicativeTypes
+ In the type signature for `foo': foo :: IO (Num a => a -> a)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail128.hs b/testsuite/tests/typecheck/should_fail/tcfail128.hs new file mode 100644 index 0000000000..08971837a2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail128.hs @@ -0,0 +1,29 @@ + + +-- Ambiguity error reporting + +module Main where + +import Data.Array.MArray (thaw,freeze) +import Data.Array.Unboxed as UA (UArray,listArray) +import Data.Array.IArray as IA (Array,listArray) + +main :: IO () +main = do let sL = [1,4,6,3,2,5] + dim = length sL + help :: [FlatVector] + help = [listFlatVector (1,s) [0|i<-[1..s]]|s<-sL] + tmp :: Vector FlatVector + tmp = listVector (1,dim) help + v <- thaw tmp + return () + +type FlatVector = UArray Int Double + +listFlatVector :: (Int,Int) -> [Double] -> FlatVector +listFlatVector = UA.listArray + +type Vector a = Array Int a + +listVector :: (Int,Int) -> [a] -> Vector a +listVector = IA.listArray diff --git a/testsuite/tests/typecheck/should_fail/tcfail128.stderr b/testsuite/tests/typecheck/should_fail/tcfail128.stderr new file mode 100644 index 0000000000..a3c99a9548 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail128.stderr @@ -0,0 +1,20 @@ + +tcfail128.hs:18:16: + No instance for (Data.Array.Base.MArray b0 FlatVector IO) + arising from a use of `thaw' + Possible fix: + add an instance declaration for + (Data.Array.Base.MArray b0 FlatVector IO) + In a stmt of a 'do' block: v <- thaw tmp + In the expression: + do { let sL = ... + dim = length sL + ....; + v <- thaw tmp; + return () } + In an equation for `main': + main + = do { let sL = ... + ....; + v <- thaw tmp; + return () } diff --git a/testsuite/tests/typecheck/should_fail/tcfail128.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail128.stderr-hugs new file mode 100644 index 0000000000..fa3977e1e9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail128.stderr-hugs @@ -0,0 +1,5 @@ +ERROR "tcfail128.hs":12 - Cannot justify constraints in explicitly typed binding +*** Expression : main +*** Type : IO () +*** Given context : () +*** Constraints : MArray a (UArray Int Double) IO diff --git a/testsuite/tests/typecheck/should_fail/tcfail129.hs b/testsuite/tests/typecheck/should_fail/tcfail129.hs new file mode 100644 index 0000000000..1a74749f56 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail129.hs @@ -0,0 +1,19 @@ +-- Both blocks are illegal Haskell 98, because of the un-saturated +-- type synonym, but (rather obscurely) at one point (GHC 6.3), we +-- acceped 'blah', but rejected 'blah1' + +module ShouldFail where + +data T = T + +-- This was erroneously accepted +type Foo a = String -> Maybe a +type Bar m = m Int +blah = undefined :: Bar Foo + + +type Foo1 a = Maybe a +type Bar1 m = m Int +blah1 = undefined :: Bar1 Foo1 + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail129.stderr b/testsuite/tests/typecheck/should_fail/tcfail129.stderr new file mode 100644 index 0000000000..f9ee8a567d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail129.stderr @@ -0,0 +1,12 @@ + +tcfail129.hs:12:8: + Type synonym `Foo' should have 1 argument, but has been given none + In an expression type signature: Bar Foo + In the expression: undefined :: Bar Foo + In an equation for `blah': blah = undefined :: Bar Foo + +tcfail129.hs:17:9: + Type synonym `Foo1' should have 1 argument, but has been given none + In an expression type signature: Bar1 Foo1 + In the expression: undefined :: Bar1 Foo1 + In an equation for `blah1': blah1 = undefined :: Bar1 Foo1 diff --git a/testsuite/tests/typecheck/should_fail/tcfail129.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail129.stderr-hugs new file mode 100644 index 0000000000..ff4f0a79c6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail129.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail129.hs":12 - Not enough arguments for type synonym "Foo" diff --git a/testsuite/tests/typecheck/should_fail/tcfail130.hs b/testsuite/tests/typecheck/should_fail/tcfail130.hs new file mode 100644 index 0000000000..96101b534a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail130.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE ImplicitParams #-} + +-- The defn of foo should be rejected; it's monomorphic, but +-- the implicit paramter escapes + +module Foo where + +baz = let ?x = 5 in print foo + +foo = woggle 3 + +woggle :: (?x :: Int) => Int -> Int +woggle y = ?x + y + + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail130.stderr b/testsuite/tests/typecheck/should_fail/tcfail130.stderr new file mode 100644 index 0000000000..3534dba679 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail130.stderr @@ -0,0 +1,6 @@ + +tcfail130.hs:10:7: + Unbound implicit parameter (?x::Int) + arising from a use of `woggle' + In the expression: woggle 3 + In an equation for `foo': foo = woggle 3 diff --git a/testsuite/tests/typecheck/should_fail/tcfail130.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail130.stderr-hugs new file mode 100644 index 0000000000..d4e366eb19 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail130.stderr-hugs @@ -0,0 +1,3 @@ +ERROR "tcfail130.hs":10 - Unresolved top-level overloading +*** Binding : foo +*** Outstanding context : (?x :: Int) diff --git a/testsuite/tests/typecheck/should_fail/tcfail131.hs b/testsuite/tests/typecheck/should_fail/tcfail131.hs new file mode 100644 index 0000000000..98b0a29c80 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail131.hs @@ -0,0 +1,7 @@ +-- Error message in monomorphic case + +module ShouldFail where + + f = (*) -- Monomorphic + g :: Num b => b -> b + g x = f x x diff --git a/testsuite/tests/typecheck/should_fail/tcfail131.stderr b/testsuite/tests/typecheck/should_fail/tcfail131.stderr new file mode 100644 index 0000000000..134b76ffb3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail131.stderr @@ -0,0 +1,11 @@ + +tcfail131.hs:7:13: + Could not deduce (b ~ Integer) + from the context (Num b) + bound by the type signature for g :: Num b => b -> b + at tcfail131.hs:7:3-13 + `b' is a rigid type variable bound by + the type signature for g :: Num b => b -> b at tcfail131.hs:7:3 + In the second argument of `f', namely `x' + In the expression: f x x + In an equation for `g': g x = f x x diff --git a/testsuite/tests/typecheck/should_fail/tcfail132.hs b/testsuite/tests/typecheck/should_fail/tcfail132.hs new file mode 100644 index 0000000000..cc933dc6ee --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail132.hs @@ -0,0 +1,19 @@ +-- Fails with a kind error. +-- The current error message was rather horrible (trac bug #312): +-- +-- Kind error: Expecting kind `k_a1JA -> k_a1JE -> k_a1JI -> *', +-- but `DUnit t' has kind `k_a1JA -> k_a1JE -> *' +-- +-- as we couldn't tidy kinds, becuase they didn't have OccNames. +-- This test recalls the bad error message. + +module ShouldFail where + +newtype Object f' f t o1 o2 = Object (f' t o1 -> f t o2) +type DUnit t o1 o2 = () + +type T f g t o1 o2 = Either (f t o1 o2) (g t o1 o2) + +type LiftObject t f' f = T (Object f' f t) (DUnit t) + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail132.stderr b/testsuite/tests/typecheck/should_fail/tcfail132.stderr new file mode 100644 index 0000000000..b25f21a809 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail132.stderr @@ -0,0 +1,7 @@ + +tcfail132.hs:17:37: + Kind mis-match + The first argument of `T' should have kind `k0 -> k1 -> k2 -> *', + but `Object f' f t' has kind `k0 -> k1 -> *' + In the type `T (Object f' f t) (DUnit t)' + In the type synonym declaration for `LiftObject' diff --git a/testsuite/tests/typecheck/should_fail/tcfail132.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail132.stderr-hugs new file mode 100644 index 0000000000..3b5f68fc7e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail132.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail132.hs":21 - Not enough arguments for type synonym "T" diff --git a/testsuite/tests/typecheck/should_fail/tcfail133.hs b/testsuite/tests/typecheck/should_fail/tcfail133.hs new file mode 100644 index 0000000000..af45be93cd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail133.hs @@ -0,0 +1,79 @@ +{-# LANGUAGE UndecidableInstances, FlexibleInstances, TypeOperators, + MultiParamTypeClasses, FunctionalDependencies, DatatypeContexts #-} + +-- This one crashed GHC 6.3 due to an error in TcSimplify.add_ors + +module Foo where + +data Zero = Zero deriving Show +data One = One deriving Show +infixl 9 :@ +data (Number a, Digit b) => a :@ b = a :@ b deriving Show + +class Digit a +instance Digit Zero +instance Digit One + +class Number a +instance Number Zero +instance Number One +instance (Number a, Digit b) => Number (a :@ b) + +--- Pretty printing of numbers --- +class PrettyNum a where + prettyNum :: a -> String + +instance PrettyNum Zero where + prettyNum _ = "0" + +instance PrettyNum One where + prettyNum _ = "1" + +instance (Number a, Digit b, PrettyNum a, PrettyNum b) + => PrettyNum (a :@ b) where + prettyNum ~(a:@b) + = prettyNum a ++ prettyNum b + +--- Digit addition --- +class (Number a, Digit b, Number c) + => AddDigit a b c | a b -> c where + addDigit :: a -> b -> c + addDigit = undefined + +instance Number a => AddDigit a Zero a +instance AddDigit Zero One One +instance AddDigit One One (One:@Zero) +instance Number a => AddDigit (a:@Zero) One (a:@One) +instance AddDigit a One a' + => AddDigit (a:@One) One (a':@Zero) + +--- Addition --- +class (Number a, Number b, Number c) + => Add a b c | a b -> c where + add :: a -> b -> c + add = undefined + +instance Number n => Add n Zero n +instance Add Zero One One +instance Add One One (One:@One) +instance Number n + => Add (n:@Zero) One (n:@One) +instance AddDigit n One r' + => Add (n:@One) One (r':@Zero) +instance (Number n1, Digit d1, Number n2, Digit n2 + ,Add n1 n2 nr', AddDigit (d1:@nr') d2 r) + => Add (n1:@d1) (n2:@d2) r + + +foo = show $ add (One:@Zero) (One:@One) + + +-- Add (One:@Zero) (One:@One) c, Show c +-- ==> Number One, Digit Zero, Number One, Digit One +-- Add One One nr', AddDigit (Zero:@nr') One c, Show c +-- +-- ==> Add One One nr', AddDigit (Zero:@nr') One c, Show c +-- +-- ==> Add One One (One:@One), AddDigit (Zero:@(One:@One)) One c, Show c +-- +-- ==> AddDigit (Zero:@(One:@One)) One c, Show c diff --git a/testsuite/tests/typecheck/should_fail/tcfail133.stderr b/testsuite/tests/typecheck/should_fail/tcfail133.stderr new file mode 100644 index 0000000000..2808159950 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail133.stderr @@ -0,0 +1,15 @@ + +tcfail133.hs:2:61: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail133.hs:68:14: + No instance for (AddDigit (Zero :@ (One :@ One)) One a0) + arising from a use of `add' + Possible fix: + add an instance declaration for + (AddDigit (Zero :@ (One :@ One)) One a0) + In the second argument of `($)', namely + `add (One :@ Zero) (One :@ One)' + In the expression: show $ add (One :@ Zero) (One :@ One) + In an equation for `foo': + foo = show $ add (One :@ Zero) (One :@ One) diff --git a/testsuite/tests/typecheck/should_fail/tcfail134.hs b/testsuite/tests/typecheck/should_fail/tcfail134.hs new file mode 100644 index 0000000000..467bffdad0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail134.hs @@ -0,0 +1,5 @@ +-- Class used as a type, recursively + +module ShouldFail where + +class XML a where toXML :: a -> XML
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/tcfail134.stderr b/testsuite/tests/typecheck/should_fail/tcfail134.stderr new file mode 100644 index 0000000000..ea302f058a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail134.stderr @@ -0,0 +1,6 @@ + +tcfail134.hs:5:33: + `XML' is not applied to enough type arguments + Expected kind `?', but `XML' has kind `* -> *' + In the type `a -> XML' + In the class declaration for `XML' diff --git a/testsuite/tests/typecheck/should_fail/tcfail134.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail134.stderr-hugs new file mode 100644 index 0000000000..3726341ee9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail134.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail134.hs":5 - Undefined type constructor "XML" diff --git a/testsuite/tests/typecheck/should_fail/tcfail135.hs b/testsuite/tests/typecheck/should_fail/tcfail135.hs new file mode 100644 index 0000000000..5cfc926085 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail135.hs @@ -0,0 +1,9 @@ +-- A missing kind check made GHC 6.4 crash on this one + +module ShoudlFail where + +class Foo f where + baa :: f a -> f + +instance Foo Maybe where + baa z = z diff --git a/testsuite/tests/typecheck/should_fail/tcfail135.stderr b/testsuite/tests/typecheck/should_fail/tcfail135.stderr new file mode 100644 index 0000000000..37274283ed --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail135.stderr @@ -0,0 +1,6 @@ + +tcfail135.hs:6:23: + `f' is not applied to enough type arguments + Expected kind `?', but `f' has kind `k0 -> *' + In the type `f a -> f' + In the class declaration for `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail135.stderr-hugs b/testsuite/tests/typecheck/should_fail/tcfail135.stderr-hugs new file mode 100644 index 0000000000..c4c792a7ab --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail135.stderr-hugs @@ -0,0 +1 @@ +ERROR "tcfail135.hs":6 - Illegal type "a b" in constructor application diff --git a/testsuite/tests/typecheck/should_fail/tcfail136.hs b/testsuite/tests/typecheck/should_fail/tcfail136.hs new file mode 100644 index 0000000000..19989d4a61 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail136.hs @@ -0,0 +1,9 @@ +-- Kind error message test
+
+module ShouldFail where
+
+type IntMap a = [a]
+
+data SymDict a = SymDict {idcounter:: Int, itot::IntMap a}
+
+data SymTable = SymTable { dict::SymDict }
diff --git a/testsuite/tests/typecheck/should_fail/tcfail136.stderr b/testsuite/tests/typecheck/should_fail/tcfail136.stderr new file mode 100644 index 0000000000..cdeff3c8a5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail136.stderr @@ -0,0 +1,7 @@ + +tcfail136.hs:9:35: + `SymDict' is not applied to enough type arguments + Expected kind `?', but `SymDict' has kind `* -> *' + In the type `SymDict' + In the definition of data constructor `SymTable' + In the data type declaration for `SymTable' diff --git a/testsuite/tests/typecheck/should_fail/tcfail137.hs b/testsuite/tests/typecheck/should_fail/tcfail137.hs new file mode 100644 index 0000000000..3d3b4e0369 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail137.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE DatatypeContexts #-} +-- Test the stupid context on newtypes +-- (GHC 6.4 dropped it on the floor by mistake) +module ShouldFail where + +newtype Floating a => Test a = Test [a] + +x = Test [False, True] diff --git a/testsuite/tests/typecheck/should_fail/tcfail137.stderr b/testsuite/tests/typecheck/should_fail/tcfail137.stderr new file mode 100644 index 0000000000..9cbe69b98d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail137.stderr @@ -0,0 +1,10 @@ + +tcfail137.hs:1:14: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail137.hs:8:5: + No instance for (Floating Bool) + arising from a use of `Test' + Possible fix: add an instance declaration for (Floating Bool) + In the expression: Test [False, True] + In an equation for `x': x = Test [False, True] diff --git a/testsuite/tests/typecheck/should_fail/tcfail138.hs b/testsuite/tests/typecheck/should_fail/tcfail138.hs new file mode 100644 index 0000000000..cf91a023f4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail138.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + FlexibleInstances, UndecidableInstances #-} +-- UndecidableInstances because (L a b) is no smaller than (C a b) + +-- This one shows up another rather subtle functional-dependecy +-- case. The error is: +-- +-- Could not deduce (C a b') from the context (C a b) +-- arising from the superclasses of an instance declaration at Foo.hs:8:0 +-- Probable fix: add (C a b') to the instance declaration superclass context +-- In the instance declaration for `C (Maybe a) a' +-- +-- Since L is a superclass of the (sought) constraint (C a b'), you might +-- think that we'd generate the superclasses (L a b') and (L a b), and now +-- the fundep will force b=b'. But GHC is very cautious about generating +-- superclasses when doing context reduction for instance declarations, +-- becasue of the danger of superclass loops. +-- +-- So, today, this program fails. It's trivial to fix by adding a fundep for C +-- class (G a, L a b) => C a b | a -> b + +-- Note: Sept 08: when fixing Trac #1470, tc138 started working! +-- This test is a very strange one (fundeps, undecidable instances), +-- so I'm just marking it as "should-succeed". It's not very clear to +-- me what the "right" answer should be; when we have the type equality +-- story more worked out we might want to think about that. + +module ShouldFail where + +class G a +class L a b | a -> b +class (G a, L a b) => C a b + +instance C a b' => G (Maybe a) +instance C a b => C (Maybe a) a +instance L (Maybe a) a diff --git a/testsuite/tests/typecheck/should_fail/tcfail138.stderr b/testsuite/tests/typecheck/should_fail/tcfail138.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail138.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail139.hs b/testsuite/tests/typecheck/should_fail/tcfail139.hs new file mode 100644 index 0000000000..af21c8afba --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail139.hs @@ -0,0 +1,6 @@ +-- Should be rejected by Haskell 98 + +module Foo where + +type Foo = Double +instance Bounded Foo diff --git a/testsuite/tests/typecheck/should_fail/tcfail139.stderr b/testsuite/tests/typecheck/should_fail/tcfail139.stderr new file mode 100644 index 0000000000..91559a9f68 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail139.stderr @@ -0,0 +1,7 @@ + +tcfail139.hs:6:10: + Illegal instance declaration for `Bounded Foo' + (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 instance declaration for `Bounded Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail140.hs b/testsuite/tests/typecheck/should_fail/tcfail140.hs new file mode 100644 index 0000000000..791dd19cf8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail140.hs @@ -0,0 +1,22 @@ +-- GHC 6.4 gave pretty horrible error messages
+-- for some of these examples
+-- c.f. SourceForge [ ghc-Bugs-1231273 ] confusing error
+
+module ShouldFail where
+
+f :: Int -> Int
+f x = x
+
+bar = f 3 9
+
+rot xs = 3 `f` 4
+
+bot xs = map (3 `f`) xs
+
+t = ((\Just x -> x) :: Maybe a -> a) (Just 1)
+
+g :: Int -> Int
+g x y = True
+
+
+
diff --git a/testsuite/tests/typecheck/should_fail/tcfail140.stderr b/testsuite/tests/typecheck/should_fail/tcfail140.stderr new file mode 100644 index 0000000000..bc888d2309 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail140.stderr @@ -0,0 +1,29 @@ + +tcfail140.hs:10:7: + The function `f' is applied to two arguments, + but its type `Int -> Int' has only one + In the expression: f 3 9 + In an equation for `bar': bar = f 3 9 + +tcfail140.hs:12:10: + The operator `f' takes two arguments, + but its type `Int -> Int' has only one + In the expression: 3 `f` 4 + In an equation for `rot': rot xs = 3 `f` 4 + +tcfail140.hs:14:15: + The operator `f' takes two arguments, + but its type `Int -> Int' has only one + In the first argument of `map', namely `(3 `f`)' + In the expression: map (3 `f`) xs + In an equation for `bot': bot xs = map (3 `f`) xs + +tcfail140.hs:16:8: + Constructor `Just' should have 1 argument, but has been given none + In the pattern: Just + In the expression: (\ Just x -> x) :: Maybe a -> a + In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1) + +tcfail140.hs:19:1: + The equation(s) for `g' have two arguments, + but its type `Int -> Int' has only one diff --git a/testsuite/tests/typecheck/should_fail/tcfail141.hs b/testsuite/tests/typecheck/should_fail/tcfail141.hs new file mode 100644 index 0000000000..12504d04f3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail141.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- Should fail, because f :: (# Int#, ByteArray# #) + +module ShouldFail where + +import GHC.Prim (Int#, ByteArray#) + +main :: IO () +main = let f = int2Integer# 0# in putStrLn "" + + +int2Integer# :: Int# -> (# Int#, ByteArray# #) +int2Integer# = undefined +-- This function doesn't have to work! +-- We just need it for its type. + diff --git a/testsuite/tests/typecheck/should_fail/tcfail141.stderr b/testsuite/tests/typecheck/should_fail/tcfail141.stderr new file mode 100644 index 0000000000..27c7ede212 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail141.stderr @@ -0,0 +1,7 @@ + +tcfail141.hs:10:12: + The variable `f' cannot have an unboxed tuple type: + (# Int#, ByteArray# #) + In the expression: let f = int2Integer# 0# in putStrLn "" + In an equation for `main': + main = let f = int2Integer# 0# in putStrLn "" diff --git a/testsuite/tests/typecheck/should_fail/tcfail142.hs b/testsuite/tests/typecheck/should_fail/tcfail142.hs new file mode 100644 index 0000000000..add92e43ab --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail142.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +-- Tests top-level ambiguity resolution +-- This made a post-6.4 GHC fall over in TcSimplify + +module ShouldFail where + +class Foo a +instance Foo (a -> b) + +foo :: Foo a => a -> () +foo = undefined + +class Bar a r +-- The same happens if we use fundeps: +-- class Bar a r | r -> a + +bar :: Bar a r => r -> () +bar = undefined + +test = foo bar diff --git a/testsuite/tests/typecheck/should_fail/tcfail142.stderr b/testsuite/tests/typecheck/should_fail/tcfail142.stderr new file mode 100644 index 0000000000..cd0161658f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail142.stderr @@ -0,0 +1,8 @@ + +tcfail142.hs:21:12: + Ambiguous type variables `a0', `r0' in the constraint: + (Bar a0 r0) arising from a use of `bar' + Probable fix: add a type signature that fixes these type variable(s) + In the first argument of `foo', namely `bar' + In the expression: foo bar + In an equation for `test': test = foo bar diff --git a/testsuite/tests/typecheck/should_fail/tcfail143.hs b/testsuite/tests/typecheck/should_fail/tcfail143.hs new file mode 100644 index 0000000000..67eb62bafb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail143.hs @@ -0,0 +1,116 @@ +{-# LANGUAGE UndecidableInstances, FlexibleInstances, + MultiParamTypeClasses, FunctionalDependencies #-} + +module Foo where + +data Z = Z +data S a = S a + +class MinMax a b c d | a b -> c d, a c d -> b, b c d -> a +instance MinMax Z Z Z Z -- (a) +instance MinMax a Z Z a -- (b) -- L1: wrongly flagged as error src. +instance MinMax Z b Z b -- (c) +instance MinMax a b c d => MinMax (S a) (S b) (S c) (S d) + -- (d) + +class Extend a b where extend :: a -> b -> b +instance Extend Z b where Z `extend` b = b +instance MinMax a b _c b => Extend a b where + _a `extend` b = b + +t :: MinMax a b _c d => a -> b -> d +t _ _ = (undefined :: d) + +n0 = Z +n1 = S n0 + +t1 = n1 `t` n0 -- L2 + +t2 = n1 `extend` n0 -- L3: uncommenting just this line produces + -- an error message pointing at L1 and L2 + -- with no mention of the real culprit, L3. + +-- t1 :: S Z -- L4: uncommenting this and L3 produces an + -- error message rightly pointing at L2 and L3. + + +{- n0 :: Z; n1 :: S Z + +Call of extend gives wanted: Extend (S Z) Z +Use instance => MinMax (S Z) Z gamma Z +FD on (b) => gamma ~ Z, Z ~ S Z + => MinMax (S Z) Z Z Z +FD on (a), 3rd fundep => Z ~ S Z + (b) again (sadly) Z ~ S Z + +-} +{- + +Here's what is happening. + +Lacking the type signature t1 :: S Z, we get + + n0 :: Z + n1 :: S v1 + t1 :: d1 with constraint ([L2] MinMax (S v1) Z c1 d1) + t2 :: Z with constraint ([L3] Extend (S v1) Z) + + [L2] MinMax (S v1) Z c1 d1, [L3] Extend (S v1) Z +---> <by instance for Extend a b> + [L2] MinMax (S v1) Z c1 d1, [L3] MinMax (S v1) Z c2 Z} +---> <combining these two constraints using (a b -> c d) + [L2] MinMax (S v1) Z c1 Z, [L3] MinMax (S v1) Z c1 Z} + +Now there are the two constraints are indistinguishable, +and both give rise to the same error: + +---> <combining first with [L1] instance MinMax a Z Z a> + c1=Z, Z=S v1 ERROR + +In either case, the error points to L1. + + +A different sequence leads to a different error: + + [L2] MinMax (S v1) Z c1 d1, [L3] Extend (S v1) Z +---> <by instance for Extend a b> + [L2] MinMax (S v1) Z c1 d1, [L3] MinMax (S v1) Z c2 Z} +---> <combining first with [L1] instance MinMax a Z Z a> + [L2] MinMax (S v1) Z Z (S2 v1), [L3] MinMax (S v1) Z c2 Z} + +Now combining the two constraints gives rise to the error, but +this time pointing to L2,L3. + +I can't explain exactly why adding the type signature for t1 +changes the order. + + +Hmm. Perhaps a good improvement strategy would be: + - first do improvement against the instance declartions + - and only then do pairwise improvement between constraints + +I've implemented that, and indeed it improves the result. +Instead of: + + Foo.hs:1:0: + Couldn't match `S Z' against `Z' + Expected type: S Z + Inferred type: Z + When using functional dependencies to combine + MinMax a Z Z a, arising from the instance declaration at Foo.hs:10:0 + MinMax (S Z) Z _c d, arising from use of `t' at Foo.hs:25:8-10 + +we get + + Foo.hs:1:0: + Couldn't match `S Z' against `Z' + Expected type: S Z + Inferred type: Z + When using functional dependencies to combine + MinMax a Z Z a, arising from the instance declaration at Foo.hs:10:0 + MinMax (S Z) Z _c Z, arising from use of `extend' at Foo.hs:27:8-15 + + +And this error in t2 is perfectly correct. You get it even if you comment +out the entire definition of t1. +-}
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/tcfail143.stderr b/testsuite/tests/typecheck/should_fail/tcfail143.stderr new file mode 100644 index 0000000000..846f8c0252 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail143.stderr @@ -0,0 +1,11 @@ + +tcfail143.hs:29:9: + Couldn't match type `S Z' with `Z' + When using functional dependencies to combine + MinMax a Z Z a, + arising from the dependency `a b -> c d' + in the instance declaration at tcfail143.hs:11:10 + MinMax (S Z) Z Z Z, + arising from a use of `extend' at tcfail143.hs:29:9-16 + In the expression: n1 `extend` n0 + In an equation for `t2': t2 = n1 `extend` n0 diff --git a/testsuite/tests/typecheck/should_fail/tcfail144.hs b/testsuite/tests/typecheck/should_fail/tcfail144.hs new file mode 100644 index 0000000000..bdeb6f6a91 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail144.hs @@ -0,0 +1,18 @@ +-- Both sets should fail in Haskell98 + +{-# LANGUAGE Haskell98 #-} + +module ShouldCompile where + + f1 :: Eq a => a -> Bool + f1 x = (x == x) || g1 True || g1 "Yes" + + g1 :: Ord a => a -> Bool + g1 y = (y <= y) || f1 True + +--------- + + f2 :: Eq a => a -> Bool + f2 x = (x == x) || g2 True || g2 "Yes" + + g2 y = (y <= y) || f2 True diff --git a/testsuite/tests/typecheck/should_fail/tcfail144.stderr b/testsuite/tests/typecheck/should_fail/tcfail144.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail144.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail145.hs b/testsuite/tests/typecheck/should_fail/tcfail145.hs new file mode 100644 index 0000000000..d33dc1892f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail145.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE RankNTypes, ScopedTypeVariables #-} + +-- This fails, because the type in the pattern doesn't exactly match +-- the context type. We don't do subsumption in patterns any more. + +-- GHC 7.0: now we do again + +module Foo where + +foo :: (forall c. c -> c) -> [Char] +foo (f :: forall a. [a] -> [a]) = f undefined + diff --git a/testsuite/tests/typecheck/should_fail/tcfail145.stderr b/testsuite/tests/typecheck/should_fail/tcfail145.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail145.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail146.hs b/testsuite/tests/typecheck/should_fail/tcfail146.hs new file mode 100644 index 0000000000..f5ab46f4c5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail146.hs @@ -0,0 +1,7 @@ +module Foo1 where
+
+-- Variant: class used as data
+class SClass a where
+ sFun :: a -> SData a
+
+data SData a = SCon (SClass a)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail146.stderr b/testsuite/tests/typecheck/should_fail/tcfail146.stderr new file mode 100644 index 0000000000..25031ae618 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail146.stderr @@ -0,0 +1,5 @@ + +tcfail146.hs:7:16: + Class `SClass' used as a type + In the definition of data constructor `SCon' + In the data type declaration for `SData' diff --git a/testsuite/tests/typecheck/should_fail/tcfail147.hs b/testsuite/tests/typecheck/should_fail/tcfail147.hs new file mode 100644 index 0000000000..1ca703a403 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail147.hs @@ -0,0 +1,7 @@ +module Foo1 where
+
+-- Variant: ill-kinded.
+class XClass a where
+ xFun :: a -> XData
+
+data XData = XCon XClass
diff --git a/testsuite/tests/typecheck/should_fail/tcfail147.stderr b/testsuite/tests/typecheck/should_fail/tcfail147.stderr new file mode 100644 index 0000000000..81e77fe648 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail147.stderr @@ -0,0 +1,7 @@ + +tcfail147.hs:7:19: + `XClass' is not applied to enough type arguments + Expected kind `?', but `XClass' has kind `k0 -> *' + In the type `XClass' + In the definition of data constructor `XCon' + In the data type declaration for `XData' diff --git a/testsuite/tests/typecheck/should_fail/tcfail148.hs b/testsuite/tests/typecheck/should_fail/tcfail148.hs new file mode 100644 index 0000000000..d80db2ccf5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail148.hs @@ -0,0 +1,8 @@ +-- This one caused a panic in GHC 6.4 + +module Foo1 where + +data List elem = Cons elem List | Nil + +t1 :: List +t1 = Cons 1 Nil diff --git a/testsuite/tests/typecheck/should_fail/tcfail148.stderr b/testsuite/tests/typecheck/should_fail/tcfail148.stderr new file mode 100644 index 0000000000..13d4293807 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail148.stderr @@ -0,0 +1,7 @@ + +tcfail148.hs:5:28: + `List' is not applied to enough type arguments + Expected kind `?', but `List' has kind `* -> *' + In the type `List' + In the definition of data constructor `Cons' + In the data type declaration for `List' diff --git a/testsuite/tests/typecheck/should_fail/tcfail149.hs b/testsuite/tests/typecheck/should_fail/tcfail149.hs new file mode 100644 index 0000000000..2479ed75c8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail149.hs @@ -0,0 +1,14 @@ +module Main where + +class C a where + op :: (Show a, Show b) => a -> b -> String + -- This class op adds a constraint on 'a' + + -- In GHC 7.0 this is fine, and it's a royal + -- pain to reject it when in H98 mode, so + -- I'm just allowing it + +instance C Int where + op x y = show x ++ " " ++ show y + +main = print (op (1::Int) 2) diff --git a/testsuite/tests/typecheck/should_fail/tcfail149.stderr b/testsuite/tests/typecheck/should_fail/tcfail149.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail149.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail149.stdout b/testsuite/tests/typecheck/should_fail/tcfail149.stdout new file mode 100644 index 0000000000..c1fcb5d3f7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail149.stdout @@ -0,0 +1 @@ +"1 2" diff --git a/testsuite/tests/typecheck/should_fail/tcfail150.hs b/testsuite/tests/typecheck/should_fail/tcfail150.hs new file mode 100644 index 0000000000..cc2ca034ef --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail150.hs @@ -0,0 +1,6 @@ +module ShouldFail where + +-- !!! constraining the type variable in a class head is illegal +-- Simpler version of tcfail149 +class Foo a where + op :: Eq a => a -> a diff --git a/testsuite/tests/typecheck/should_fail/tcfail150.stderr b/testsuite/tests/typecheck/should_fail/tcfail150.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail150.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail151.hs b/testsuite/tests/typecheck/should_fail/tcfail151.hs new file mode 100644 index 0000000000..112973b71e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail151.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE DatatypeContexts #-} +module ShouldFail where + +class (Show a, Eq a, Monad m) => Name m a where + hashName :: a -> Int + newName :: m a + +data Name a => Exp a = MkExp a +-- The kind error should be reported here +-- GHC 6.4 reported an error with the class decl + diff --git a/testsuite/tests/typecheck/should_fail/tcfail151.stderr b/testsuite/tests/typecheck/should_fail/tcfail151.stderr new file mode 100644 index 0000000000..bf549602e7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail151.stderr @@ -0,0 +1,8 @@ + +tcfail151.hs:1:14: + Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +tcfail151.hs:8:6: + `Name a' is not applied to enough type arguments + Expected kind `?', but `Name a' has kind `* -> *' + In the data type declaration for `Exp' diff --git a/testsuite/tests/typecheck/should_fail/tcfail152.hs b/testsuite/tests/typecheck/should_fail/tcfail152.hs new file mode 100644 index 0000000000..3ebb6fe0f6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail152.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE ExistentialQuantification #-} +
+-- This test made Hugs fail (Oct 05) because the constraint
+-- from the 'toInteger' call escaped from the pattern match
+
+module ShouldFail where
+
+data T = forall a. C a
+
+test (C x) = toInteger x
diff --git a/testsuite/tests/typecheck/should_fail/tcfail152.stderr b/testsuite/tests/typecheck/should_fail/tcfail152.stderr new file mode 100644 index 0000000000..5ae2f52f00 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail152.stderr @@ -0,0 +1,6 @@ + +tcfail152.hs:10:14: + No instance for (Integral a) + arising from a use of `toInteger' + In the expression: toInteger x + In an equation for `test': test (C x) = toInteger x diff --git a/testsuite/tests/typecheck/should_fail/tcfail153.hs b/testsuite/tests/typecheck/should_fail/tcfail153.hs new file mode 100644 index 0000000000..add0479980 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail153.hs @@ -0,0 +1,8 @@ +-- Killed a test compiler, so I thought it was worth including + +module ShouldFail where + +f :: a -> [a] +f x = g x + where + g y = if y then [] else [y] diff --git a/testsuite/tests/typecheck/should_fail/tcfail153.stderr b/testsuite/tests/typecheck/should_fail/tcfail153.stderr new file mode 100644 index 0000000000..0b40df47d1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail153.stderr @@ -0,0 +1,12 @@ + +tcfail153.hs:6:9: + Couldn't match type `a' with `Bool' + `a' is a rigid type variable bound by + the type signature for f :: a -> [a] at tcfail153.hs:6:1 + In the first argument of `g', namely `x' + In the expression: g x + In an equation for `f': + f x + = g x + where + g y = if y then [] else [...] diff --git a/testsuite/tests/typecheck/should_fail/tcfail154.hs b/testsuite/tests/typecheck/should_fail/tcfail154.hs new file mode 100644 index 0000000000..6e3161bd46 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail154.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +module ShouldFail where + +data T a = MkT + +class C a b where + op :: T a -> T b -> Bool + +-- Repeated type variable in an instance constraint +-- should require UndecidableInstances +instance C a a => Eq (T a) where + (==) = op diff --git a/testsuite/tests/typecheck/should_fail/tcfail154.stderr b/testsuite/tests/typecheck/should_fail/tcfail154.stderr new file mode 100644 index 0000000000..f8f3d69a4c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail154.stderr @@ -0,0 +1,6 @@ + +tcfail154.hs:12:10: + Variable occurs more often in a constraint than in the instance head + in the constraint: C a a + (Use -XUndecidableInstances to permit this) + In the instance declaration for `Eq (T a)' diff --git a/testsuite/tests/typecheck/should_fail/tcfail155.hs b/testsuite/tests/typecheck/should_fail/tcfail155.hs new file mode 100644 index 0000000000..265d9d83a9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail155.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE GADTs #-} + +-- Data type returns the wrong type + +module ShouldFail where + +data T a where + P :: L1 -> L2 + +data L1 = L1 +data L2 = L2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail155.stderr b/testsuite/tests/typecheck/should_fail/tcfail155.stderr new file mode 100644 index 0000000000..fcc1133d4d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail155.stderr @@ -0,0 +1,6 @@ + +tcfail155.hs:8:6: + Data constructor `P' returns type `L2' + instead of an instance of its parent type `T a' + In the definition of data constructor `P' + In the data type declaration for `T' diff --git a/testsuite/tests/typecheck/should_fail/tcfail156.hs b/testsuite/tests/typecheck/should_fail/tcfail156.hs new file mode 100644 index 0000000000..7956c5b76a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail156.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- Illegal existential context on a newtype + +module ShouldFail where + +newtype Foo = forall a . Foo a + diff --git a/testsuite/tests/typecheck/should_fail/tcfail156.stderr b/testsuite/tests/typecheck/should_fail/tcfail156.stderr new file mode 100644 index 0000000000..d93549e136 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail156.stderr @@ -0,0 +1,6 @@ + +tcfail156.hs:7:26: + A newtype constructor cannot have an existential context, + but `Foo' does + In the definition of data constructor `Foo' + In the newtype declaration for `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail157.hs b/testsuite/tests/typecheck/should_fail/tcfail157.hs new file mode 100644 index 0000000000..74f02ed1e5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail157.hs @@ -0,0 +1,39 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + FlexibleInstances #-} +-- NB: *no* UndecidableInstances + +-- This one (due to Oleg) made 6.4.1 go into a loop in the typechecker, +-- despite the lack of UndecidableInstances +-- +-- The example corresponds to a type function (realized as a class E +-- with functional dependencies) in the context of an instance. +-- The function in question is +-- +-- class E m a b | m a -> b +-- instance E m (() -> ()) (m ()) +-- +-- We see that the result of the function, "m ()" is smaller (in the +-- number of constructors) that the functions' arguments, "m" and +-- "() -> ()" together. Plus any type variable free in the result is also +-- free in at least one of the arguments. And yet it loops. +module ShouldFail where + +class Foo m a where + foo :: m b -> a -> Bool + +instance Foo m () where + foo _ _ = True + +instance (E m a b, Foo m b) => Foo m (a->()) where + foo m f = undefined + +class E m a b | m a -> b where + tr :: m c -> a -> b + +-- There is only one instance of the class with functional dependencies +instance E m (() -> ()) (m ()) where + tr x = undefined + +-- GHC(i) loops + +test = foo (\f -> (f ()) :: ()) (\f -> (f ()) :: ()) diff --git a/testsuite/tests/typecheck/should_fail/tcfail157.stderr b/testsuite/tests/typecheck/should_fail/tcfail157.stderr new file mode 100644 index 0000000000..c68f957652 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail157.stderr @@ -0,0 +1,12 @@ + +tcfail157.hs:27:10: + Variable occurs more often in a constraint than in the instance head + in the constraint: E m a b + (Use -XUndecidableInstances to permit this) + In the instance declaration for `Foo m (a -> ())' + +tcfail157.hs:27:10: + Variable occurs more often in a constraint than in the instance head + in the constraint: Foo m b + (Use -XUndecidableInstances to permit this) + In the instance declaration for `Foo m (a -> ())' diff --git a/testsuite/tests/typecheck/should_fail/tcfail158.hs b/testsuite/tests/typecheck/should_fail/tcfail158.hs new file mode 100644 index 0000000000..95af345b36 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail158.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE ExplicitForAll #-} + +-- This one actually crashed in 6.4.1 +-- There's a kind error in the signature for bar, +-- and we were recovering, and then crashing when we found +-- a scoped type variable not in scope + + data Val v sm = Val + foo :: forall v sm. Val v sm + foo = undefined + where foo1 :: Val v sm + foo1 = bar + -- Correct type signature: bar :: forall v sm. Val v sm + bar :: forall v. Val v + bar = undefined foo diff --git a/testsuite/tests/typecheck/should_fail/tcfail158.stderr b/testsuite/tests/typecheck/should_fail/tcfail158.stderr new file mode 100644 index 0000000000..b9c3a7dbca --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail158.stderr @@ -0,0 +1,6 @@ + +tcfail158.hs:14:19: + `Val v' is not applied to enough type arguments + Expected kind `*', but `Val v' has kind `* -> *' + In the type signature for `bar': + bar :: forall v. Val v diff --git a/testsuite/tests/typecheck/should_fail/tcfail159.hs b/testsuite/tests/typecheck/should_fail/tcfail159.hs new file mode 100644 index 0000000000..c0c2eb1902 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail159.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE UnboxedTuples #-} + +module ShouldFail where + +h :: Int -> (# Int, Int #) +h x = (# x,x #) + +foo x = case h x of + ~(# p, q #) -> p diff --git a/testsuite/tests/typecheck/should_fail/tcfail159.stderr b/testsuite/tests/typecheck/should_fail/tcfail159.stderr new file mode 100644 index 0000000000..b389ef1e96 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail159.stderr @@ -0,0 +1,8 @@ + +tcfail159.hs:9:11: + Kind incompatibility when matching types: + t0 :: * + (# Int, Int #) :: (#) + In the pattern: ~(# p, q #) + In a case alternative: ~(# p, q #) -> p + In the expression: case h x of { ~(# p, q #) -> p } diff --git a/testsuite/tests/typecheck/should_fail/tcfail160.hs b/testsuite/tests/typecheck/should_fail/tcfail160.hs new file mode 100644 index 0000000000..79b75df305 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail160.hs @@ -0,0 +1,8 @@ +-- Kind error message + +module ShouldFail where + +data T k = T (k Int) + +g :: T Int +g x = x diff --git a/testsuite/tests/typecheck/should_fail/tcfail160.stderr b/testsuite/tests/typecheck/should_fail/tcfail160.stderr new file mode 100644 index 0000000000..33cbbbb8f1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail160.stderr @@ -0,0 +1,7 @@ + +tcfail160.hs:7:8: + Kind mis-match + The first argument of `T' should have kind `* -> *', + but `Int' has kind `*' + In the type signature for `g': + g :: T Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail161.hs b/testsuite/tests/typecheck/should_fail/tcfail161.hs new file mode 100644 index 0000000000..6ebdfddc85 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail161.hs @@ -0,0 +1,7 @@ +-- Kind error message + +module ShouldFail where + +f :: [Maybe] +f x = x + diff --git a/testsuite/tests/typecheck/should_fail/tcfail161.stderr b/testsuite/tests/typecheck/should_fail/tcfail161.stderr new file mode 100644 index 0000000000..0b04d8ef02 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail161.stderr @@ -0,0 +1,6 @@ + +tcfail161.hs:5:7: + `Maybe' is not applied to enough type arguments + Expected kind `*', but `Maybe' has kind `* -> *' + In the type signature for `f': + f :: [Maybe] diff --git a/testsuite/tests/typecheck/should_fail/tcfail162.hs b/testsuite/tests/typecheck/should_fail/tcfail162.hs new file mode 100644 index 0000000000..b13ccaa33e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail162.hs @@ -0,0 +1,12 @@ + + + +-- Kind error messsage should not contain bangs + +module ShouldFail where + +import Foreign.ForeignPtr + +data Foo = Foo {-# UNPACK #-} !(ForeignPtr) + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail162.stderr b/testsuite/tests/typecheck/should_fail/tcfail162.stderr new file mode 100644 index 0000000000..ae7b1c5d27 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail162.stderr @@ -0,0 +1,7 @@ + +tcfail162.hs:10:16: + `ForeignPtr' is not applied to enough type arguments + Expected kind `?', but `ForeignPtr' has kind `* -> *' + In the type `{-# UNPACK #-} !ForeignPtr' + In the definition of data constructor `Foo' + In the data type declaration for `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail164.hs b/testsuite/tests/typecheck/should_fail/tcfail164.hs new file mode 100644 index 0000000000..97ff3caf4e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail164.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} + +-- Tests tagToEnum# hacks + +module ShouldFail where + +import GHC.Base + +-- Test 1: Polymorphic +f :: a +f = tagToEnum# 0# + +-- Test 2: Int value (not an Enumeration TyCon) +class Unboxable value where + readUnboxable :: Int -> value +instance Unboxable Int where + readUnboxable (I# value#) = tagToEnum# value# + diff --git a/testsuite/tests/typecheck/should_fail/tcfail164.stderr b/testsuite/tests/typecheck/should_fail/tcfail164.stderr new file mode 100644 index 0000000000..65f9c9f9ac --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail164.stderr @@ -0,0 +1,15 @@ + +tcfail164.hs:11:5: + Bad call to tagToEnum# at type a + Specify the type by giving a type signature + e.g. (tagToEnum# x) :: Bool + In the expression: tagToEnum# 0# + In an equation for `f': f = tagToEnum# 0# + +tcfail164.hs:17:34: + Bad call to tagToEnum# at type Int + Result type must be an enumeration type + In the expression: tagToEnum# value# + In an equation for `readUnboxable': + readUnboxable (I# value#) = tagToEnum# value# + In the instance declaration for `Unboxable Int' diff --git a/testsuite/tests/typecheck/should_fail/tcfail165.hs b/testsuite/tests/typecheck/should_fail/tcfail165.hs new file mode 100644 index 0000000000..c23a7f39b4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail165.hs @@ -0,0 +1,16 @@ +{-# OPTIONS -XImpredicativeTypes -fno-warn-deprecated-flags #-} + +module ShouldFail where + +import Control.Concurrent + +-- Attempt to put a polymorphic value in an MVar +-- Fails, but the error message is worth keeping an eye on +-- +-- Actually (Dec 06) it succeeds now +-- +-- In GHC 7.0 it fails again! (and rightly so) + +foo = do var <- newEmptyMVar :: IO (MVar (forall a. Show a => a -> String)) + putMVar var (show :: forall b. Show b => b -> String) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail165.stderr b/testsuite/tests/typecheck/should_fail/tcfail165.stderr new file mode 100644 index 0000000000..878a707120 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail165.stderr @@ -0,0 +1,12 @@ + +tcfail165.hs:15:23: + Couldn't match expected type `forall a. Show a => a -> String' + with actual type `b0 -> String' + In the second argument of `putMVar', namely + `(show :: forall b. Show b => b -> String)' + In a stmt of a 'do' block: + putMVar var (show :: forall b. Show b => b -> String) + In the expression: + do { var <- newEmptyMVar :: + IO (MVar (forall a. Show a => a -> String)); + putMVar var (show :: forall b. Show b => b -> String) } diff --git a/testsuite/tests/typecheck/should_fail/tcfail166.hs b/testsuite/tests/typecheck/should_fail/tcfail166.hs new file mode 100644 index 0000000000..5a2d4b8df7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail166.hs @@ -0,0 +1,6 @@ +-- Without -XScopedTypeVariables, this should fail + +module ShouldFail where + +destroy :: (forall a. (a -> Maybe (b,a)) -> a -> c) -> [b] -> c +destroy = error "urk" diff --git a/testsuite/tests/typecheck/should_fail/tcfail166.stderr b/testsuite/tests/typecheck/should_fail/tcfail166.stderr new file mode 100644 index 0000000000..3907418e10 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail166.stderr @@ -0,0 +1,5 @@ + +tcfail166.hs:5:21: + Illegal symbol '.' in type + Perhaps you intended -XRankNTypes or similar flag + to enable explicit-forall syntax: forall <tvs>. <type> diff --git a/testsuite/tests/typecheck/should_fail/tcfail167.hs b/testsuite/tests/typecheck/should_fail/tcfail167.hs new file mode 100644 index 0000000000..b4d404a74d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail167.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE GADTs #-} +{-# OPTIONS_GHC -fwarn-incomplete-patterns #-} +-- Test inspired by trac #366 +-- The C2 case is impossible due to the types + +module ShouldCompile where + +data T a where + C1 :: T Char + C2 :: T Float + +inaccessible :: T Char -> Char +inaccessible C1 = ' ' +inaccessible C2 = ' ' + diff --git a/testsuite/tests/typecheck/should_fail/tcfail167.stderr b/testsuite/tests/typecheck/should_fail/tcfail167.stderr new file mode 100644 index 0000000000..f62f524ebd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail167.stderr @@ -0,0 +1,9 @@ + +tcfail167.hs:14:14: + Couldn't match type `Char' with `Float' + Inaccessible code in + a pattern with constructor + C2 :: T Float, + in an equation for `inaccessible' + In the pattern: C2 + In an equation for `inaccessible': inaccessible C2 = ' ' diff --git a/testsuite/tests/typecheck/should_fail/tcfail168.hs b/testsuite/tests/typecheck/should_fail/tcfail168.hs new file mode 100644 index 0000000000..94a78a93b0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail168.hs @@ -0,0 +1,66 @@ + +-- Test trac #719 (shouldn't give the entire do block in the error message) + +module ShouldFail where + +foo = do + putChar + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + putChar 'a' + diff --git a/testsuite/tests/typecheck/should_fail/tcfail168.stderr b/testsuite/tests/typecheck/should_fail/tcfail168.stderr new file mode 100644 index 0000000000..f16f65bdb1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail168.stderr @@ -0,0 +1,12 @@ + +tcfail168.hs:8:11: + Couldn't match expected type `Char -> a0' with actual type `IO ()' + In the return type of a call of `putChar' + Probable cause: `putChar' is applied to too many arguments + In a stmt of a 'do' block: putChar 'a' + In the expression: + do { putChar; + putChar 'a'; + putChar 'a'; + putChar 'a'; + .... } diff --git a/testsuite/tests/typecheck/should_fail/tcfail169.hs b/testsuite/tests/typecheck/should_fail/tcfail169.hs new file mode 100644 index 0000000000..e0d6e4f838 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail169.hs @@ -0,0 +1,8 @@ + +-- Trac #958 + +module ShoulFail where + +data Succ a = S a -- NB: deriving Show omitted +data Seq a = Cons a (Seq (Succ a)) | Nil deriving Show + diff --git a/testsuite/tests/typecheck/should_fail/tcfail169.stderr b/testsuite/tests/typecheck/should_fail/tcfail169.stderr new file mode 100644 index 0000000000..cfe63c06ee --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail169.stderr @@ -0,0 +1,9 @@ + +tcfail169.hs:7:51: + No instance for (Show (Succ a)) + arising from the 'deriving' clause of a data type declaration + Possible fix: + add an instance declaration for (Show (Succ a)) + or use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself + When deriving the instance for (Show (Seq a)) diff --git a/testsuite/tests/typecheck/should_fail/tcfail170.hs b/testsuite/tests/typecheck/should_fail/tcfail170.hs new file mode 100644 index 0000000000..1e7838cb43 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail170.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} + +module ShouldFail where + +class C a b | a -> b + +instance C [p] [q] + -- Coverage condition fails diff --git a/testsuite/tests/typecheck/should_fail/tcfail170.stderr b/testsuite/tests/typecheck/should_fail/tcfail170.stderr new file mode 100644 index 0000000000..914ab0cde0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail170.stderr @@ -0,0 +1,6 @@ + +tcfail170.hs:7:10: + Illegal instance declaration for `C [p] [q]' + (the Coverage Condition fails for one of the functional dependencies; + Use -XUndecidableInstances to permit this) + In the instance declaration for `C [p] [q]' diff --git a/testsuite/tests/typecheck/should_fail/tcfail171.hs b/testsuite/tests/typecheck/should_fail/tcfail171.hs new file mode 100644 index 0000000000..fb8e4b652c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail171.hs @@ -0,0 +1,9 @@ +module ShouldFail where + +-- This one made GHC fall over on implication constraints +-- Silly, but one more test does no harm + +import Text.Printf + +phex :: a -> b +phex x = printf "0x%x" x diff --git a/testsuite/tests/typecheck/should_fail/tcfail171.stderr b/testsuite/tests/typecheck/should_fail/tcfail171.stderr new file mode 100644 index 0000000000..b4efd33e32 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail171.stderr @@ -0,0 +1,6 @@ + +tcfail171.hs:9:10: + No instances for (PrintfType b, PrintfArg a) + arising from a use of `printf' + In the expression: printf "0x%x" x + In an equation for `phex': phex x = printf "0x%x" x diff --git a/testsuite/tests/typecheck/should_fail/tcfail172.hs b/testsuite/tests/typecheck/should_fail/tcfail172.hs new file mode 100644 index 0000000000..bb31501cec --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail172.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE GADTs #-} + +-- This one made GHC 6.6 give the very unhelpful error +-- Foo8.hs:11:10: +-- Couldn't match kind `?' against `* -> * -> *' +-- When matching the kinds of `t :: ?' and `t1 :: * -> * -> *' +-- Expected type: t1 +-- Inferred type: t +-- In the pattern: Nil + +module ShouldFail where + +data PatchSeq p a b where + Nil :: PatchSeq p a a + U :: p a b -> PatchSeq p a b + (:-) :: PatchSeq p a b -> PatchSeq p b c -> PatchSeq p a c + +-- is_normal :: PatchSeq p a b -> Bool +is_normal Nil = True +is_normal (U _) = True +is_normal (U _ :- _) = True +is_normal _ = False diff --git a/testsuite/tests/typecheck/should_fail/tcfail172.stderr b/testsuite/tests/typecheck/should_fail/tcfail172.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail172.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail173.hs b/testsuite/tests/typecheck/should_fail/tcfail173.hs new file mode 100644 index 0000000000..bad14bd539 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail173.hs @@ -0,0 +1,5 @@ + + +module ShouldFail where + +newtype (f <.> g) a = Compose (f (g a)) diff --git a/testsuite/tests/typecheck/should_fail/tcfail173.stderr b/testsuite/tests/typecheck/should_fail/tcfail173.stderr new file mode 100644 index 0000000000..ee8f59b525 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail173.stderr @@ -0,0 +1,3 @@ + +tcfail173.hs:5:10: + Malformed head of type or class declaration: (f <.> g) a diff --git a/testsuite/tests/typecheck/should_fail/tcfail174.hs b/testsuite/tests/typecheck/should_fail/tcfail174.hs new file mode 100644 index 0000000000..47c63d7248 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail174.hs @@ -0,0 +1,17 @@ +{-# OPTIONS -XImpredicativeTypes #-} + +module Foo where + +data Capture a = Base a + | Capture (Capture (forall x . x -> a)) + +g :: Capture (forall a . a -> a) +g = Base id -- Fails; need a rigid signature on 'id' + +-- This function should definitely be rejected, with or without type signature + +h1 = Capture g + +h2 :: Capture b +h2 = Capture g + diff --git a/testsuite/tests/typecheck/should_fail/tcfail174.stderr b/testsuite/tests/typecheck/should_fail/tcfail174.stderr new file mode 100644 index 0000000000..84c0868db4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail174.stderr @@ -0,0 +1,23 @@ + +tcfail174.hs:9:10: + Couldn't match expected type `forall a. a -> a' + with actual type `a0 -> a0' + In the first argument of `Base', namely `id' + In the expression: Base id + In an equation for `g': g = Base id + +tcfail174.hs:13:14: + Couldn't match expected type `forall x. x -> a0' + with actual type `forall a. a -> a' + Expected type: Capture (forall x. x -> a0) + Actual type: Capture (forall a. a -> a) + In the first argument of `Capture', namely `g' + In the expression: Capture g + +tcfail174.hs:16:14: + Couldn't match expected type `forall x. x -> b' + with actual type `forall a. a -> a' + Expected type: Capture (forall x. x -> b) + Actual type: Capture (forall a. a -> a) + In the first argument of `Capture', namely `g' + In the expression: Capture g diff --git a/testsuite/tests/typecheck/should_fail/tcfail175.hs b/testsuite/tests/typecheck/should_fail/tcfail175.hs new file mode 100644 index 0000000000..5eacd24291 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail175.hs @@ -0,0 +1,12 @@ + +-- Crashed GHC 6.6! +-- Trac #1153 + +module ShouldFail where + +eval :: Int -> String -> String -> String +eval 0 root actual = evalRHS 0 root actual + +evalRHS :: Int -> a +evalRHS 0 root actual = eval 0 root actual + diff --git a/testsuite/tests/typecheck/should_fail/tcfail175.stderr b/testsuite/tests/typecheck/should_fail/tcfail175.stderr new file mode 100644 index 0000000000..f181c00bcd --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail175.stderr @@ -0,0 +1,7 @@ + +tcfail175.hs:11:1: + Couldn't match type `a' with `String -> String -> String' + `a' is a rigid type variable bound by + the type signature for evalRHS :: Int -> a at tcfail175.hs:11:1 + The equation(s) for `evalRHS' have three arguments, + but its type `Int -> a' has only one diff --git a/testsuite/tests/typecheck/should_fail/tcfail176.hs b/testsuite/tests/typecheck/should_fail/tcfail176.hs new file mode 100644 index 0000000000..39f3818ede --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail176.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE GADTs #-} + +-- Newtype in GADT syntax + +module ShouldFail where + +newtype Bug a where Bug :: a -> Maybe a diff --git a/testsuite/tests/typecheck/should_fail/tcfail176.stderr b/testsuite/tests/typecheck/should_fail/tcfail176.stderr new file mode 100644 index 0000000000..f804b000cf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail176.stderr @@ -0,0 +1,6 @@ + +tcfail176.hs:7:21: + Data constructor `Bug' returns type `Maybe a' + instead of an instance of its parent type `Bug a' + In the definition of data constructor `Bug' + In the newtype declaration for `Bug' diff --git a/testsuite/tests/typecheck/should_fail/tcfail177.hs b/testsuite/tests/typecheck/should_fail/tcfail177.hs new file mode 100644 index 0000000000..d9e60e96fc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail177.hs @@ -0,0 +1,34 @@ +module ShouldFail where + +-- See Trac #1176 +-- This is really a pretty-printer test, not a typechecker test +-- The more infix ops we have, the worse fsep works + +-- Currently the error message looks ok, however + +allTests :: Bool +allTests = foo + [a ~?= b + ,"Three" ~?= "3" + ,"Four" ~?= "4" + ,"Five" ~?= "5" + ,"Five" ~?= "5" + ,"Five" ~?= "5" + ,"Five" ~?= "5" + ,"Five" ~?= "5" + ,"Five" ~?= "5" + ,"Two", "Two", "Two" + ,"Two", "Two", "Two" + ,"Two", "Two", "Two" + ,"Two", "Two", "Two" + ,"Two", "Two", "Two" + ,"Two", "Two", "Two"] + +a="" +b="" + +(~?=) :: a -> a -> Bool +(~?=) = error "urk" + +foo :: a -> Int +foo x = 0 diff --git a/testsuite/tests/typecheck/should_fail/tcfail177.stderr b/testsuite/tests/typecheck/should_fail/tcfail177.stderr new file mode 100644 index 0000000000..3107d1e668 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail177.stderr @@ -0,0 +1,9 @@ + +tcfail177.hs:10:12: + Couldn't match expected type `Bool' with actual type `Int' + In the return type of a call of `foo' + In the expression: + foo + [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] + In an equation for `allTests': + allTests = foo [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", ....] diff --git a/testsuite/tests/typecheck/should_fail/tcfail178.hs b/testsuite/tests/typecheck/should_fail/tcfail178.hs new file mode 100644 index 0000000000..8071def02e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail178.hs @@ -0,0 +1,19 @@ +-- See Trac #1221 + +module ShouldFail where + +a :: Num a => (Bool -> [a]) -> [a] +a x = x True ++ [1] + +y :: b -> () +y = const () + +-- Typechecks ok +b = a (const [2]) + +-- This one had an uninformative error message +c = a y + +-- More informative +d = a () + diff --git a/testsuite/tests/typecheck/should_fail/tcfail178.stderr b/testsuite/tests/typecheck/should_fail/tcfail178.stderr new file mode 100644 index 0000000000..63119af75e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail178.stderr @@ -0,0 +1,13 @@ + +tcfail178.hs:15:7: + Couldn't match expected type `[a0]' with actual type `()' + Expected type: Bool -> [a0] + Actual type: Bool -> () + In the first argument of `a', namely `y' + In the expression: a y + +tcfail178.hs:18:7: + Couldn't match expected type `Bool -> [a0]' with actual type `()' + In the first argument of `a', namely `()' + In the expression: a () + In an equation for `d': d = a () diff --git a/testsuite/tests/typecheck/should_fail/tcfail179.hs b/testsuite/tests/typecheck/should_fail/tcfail179.hs new file mode 100644 index 0000000000..a270cbffb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail179.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE ExistentialQuantification #-} + +-- Exmaples from Doaitse Swierestra and Brandon Moore +-- GHC users mailing list, April 07, title "Release plans" + +-- This one should fail, but Hugs passes it + +module ShouldFail where + +data T s = forall x. T (s -> (x -> s) -> (x, s, Int)) + +run :: T s -> Int +run ts = case ts of + T g -> let (x,_, b) = g x id + in b + diff --git a/testsuite/tests/typecheck/should_fail/tcfail179.stderr b/testsuite/tests/typecheck/should_fail/tcfail179.stderr new file mode 100644 index 0000000000..ba995b65ea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail179.stderr @@ -0,0 +1,14 @@ + +tcfail179.hs:14:41: + Couldn't match type `x' with `s' + `x' is a rigid type variable bound by + a pattern with constructor + T :: forall s x. (s -> (x -> s) -> (x, s, Int)) -> T s, + in a case alternative + at tcfail179.hs:14:14 + `s' is a rigid type variable bound by + the type signature for run :: T s -> Int at tcfail179.hs:13:1 + Expected type: x -> s + Actual type: x -> x + In the second argument of `g', namely `id' + In the expression: g x id diff --git a/testsuite/tests/typecheck/should_fail/tcfail180.hs b/testsuite/tests/typecheck/should_fail/tcfail180.hs new file mode 100644 index 0000000000..4c228eedda --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail180.hs @@ -0,0 +1,10 @@ + +-- Showed up a bug in bodySplitTyConApp + +module ShouldFail where + +p :: f b +p = error "urk" + +g x = case p of + True -> () diff --git a/testsuite/tests/typecheck/should_fail/tcfail180.stderr b/testsuite/tests/typecheck/should_fail/tcfail180.stderr new file mode 100644 index 0000000000..96d76100ea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail180.stderr @@ -0,0 +1,6 @@ + +tcfail180.hs:10:9: + Couldn't match expected type `f0 b0' with actual type `Bool' + In the pattern: True + In a case alternative: True -> () + In the expression: case p of { True -> () } diff --git a/testsuite/tests/typecheck/should_fail/tcfail181.hs b/testsuite/tests/typecheck/should_fail/tcfail181.hs new file mode 100644 index 0000000000..01d06599ef --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail181.hs @@ -0,0 +1,18 @@ +-- GHC 6.7 at one point said wog's type was: +-- +-- wog :: forall t e (m :: * -> *). +-- (Monad GHC.Prim.Any1, Monad m) => +-- t -> Something (m Bool) e +-- +-- The stupid 'GHC.Prim.Any1' arose becuase of type ambiguity +-- which should be reported, and wasn't. + +module ShouldFail where + +data Something d e = Something{ bar:: d, initializer::e } + +foo :: (Monad m) => Something (m Bool) n +foo = undefined + +wog x = foo{bar = return True} + diff --git a/testsuite/tests/typecheck/should_fail/tcfail181.stderr b/testsuite/tests/typecheck/should_fail/tcfail181.stderr new file mode 100644 index 0000000000..59fe8b83af --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail181.stderr @@ -0,0 +1,8 @@ + +tcfail181.hs:17:9: + Ambiguous type variable `m0' in the constraint: + (Monad m0) arising from a use of `foo' + Probable fix: add a type signature that fixes these type variable(s) + In the expression: foo + In the expression: foo {bar = return True} + In an equation for `wog': wog x = foo {bar = return True} diff --git a/testsuite/tests/typecheck/should_fail/tcfail182.hs b/testsuite/tests/typecheck/should_fail/tcfail182.hs new file mode 100644 index 0000000000..7b04df489f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail182.hs @@ -0,0 +1,9 @@ +module Foo where + +import qualified Prelude +import Prelude hiding( Maybe ) + +data Maybe a = Foo + +f :: Prelude.Maybe a -> Int +f Foo = 3 diff --git a/testsuite/tests/typecheck/should_fail/tcfail182.stderr b/testsuite/tests/typecheck/should_fail/tcfail182.stderr new file mode 100644 index 0000000000..d6b97af250 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail182.stderr @@ -0,0 +1,6 @@ + +tcfail182.hs:9:3: + Couldn't match expected type `Prelude.Maybe a' + with actual type `Maybe t0' + In the pattern: Foo + In an equation for `f': f Foo = 3 diff --git a/testsuite/tests/typecheck/should_fail/tcfail183.hs b/testsuite/tests/typecheck/should_fail/tcfail183.hs new file mode 100644 index 0000000000..d46d87ad7c --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail183.hs @@ -0,0 +1,4 @@ + +module ShouldCompile where + +newtype Swizzle = MkSwizzle (forall a. Ord a => [a] -> [a]) diff --git a/testsuite/tests/typecheck/should_fail/tcfail183.stderr b/testsuite/tests/typecheck/should_fail/tcfail183.stderr new file mode 100644 index 0000000000..fad1ccf736 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail183.stderr @@ -0,0 +1,5 @@ + +tcfail183.hs:4:38: + Illegal symbol '.' in type + Perhaps you intended -XRankNTypes or similar flag + to enable explicit-forall syntax: forall <tvs>. <type> diff --git a/testsuite/tests/typecheck/should_fail/tcfail184.hs b/testsuite/tests/typecheck/should_fail/tcfail184.hs new file mode 100644 index 0000000000..210a9c7c9b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail184.hs @@ -0,0 +1,8 @@ + +{-# OPTIONS_GHC -XScopedTypeVariables #-} +-- We don't actually want scoped type variables, but this flag makes the +-- forall be recognised by the parser + +module ShouldCompile where + +newtype Swizzle = MkSwizzle (forall a. Ord a => [a] -> [a]) diff --git a/testsuite/tests/typecheck/should_fail/tcfail184.stderr b/testsuite/tests/typecheck/should_fail/tcfail184.stderr new file mode 100644 index 0000000000..20920d822b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail184.stderr @@ -0,0 +1,7 @@ +
+tcfail184.hs:8:19:
+ Illegal polymorphic or qualified type:
+ forall a. Ord a => [a] -> [a]
+ Perhaps you intended to use -XRankNTypes or -XRank2Types
+ In the definition of data constructor `MkSwizzle'
+ In the newtype declaration for `Swizzle'
diff --git a/testsuite/tests/typecheck/should_fail/tcfail185.hs b/testsuite/tests/typecheck/should_fail/tcfail185.hs new file mode 100644 index 0000000000..59af50f738 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail185.hs @@ -0,0 +1,13 @@ +-- See Trac #1606 + +module ShouldFail where + +f :: Int -> Int -> Bool -> Bool -> Int -> Int +f a b = \ x y -> let { y1 = y; y2 = y1; y3 = y2; y4 = y3; y5 = y4; + y6 = y5; y7 = y6 } in x + + + + + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail185.stderr b/testsuite/tests/typecheck/should_fail/tcfail185.stderr new file mode 100644 index 0000000000..1e4c8d718f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail185.stderr @@ -0,0 +1,17 @@ + +tcfail185.hs:7:46: + Couldn't match expected type `Int -> Int' with actual type `Bool' + In the expression: x + In the expression: + let + y1 = y + y2 = y1 + y3 = y2 + .... + in x + In the expression: + \ x y + -> let + y1 = ... + .... + in x diff --git a/testsuite/tests/typecheck/should_fail/tcfail186.hs b/testsuite/tests/typecheck/should_fail/tcfail186.hs new file mode 100644 index 0000000000..6148517a6d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail186.hs @@ -0,0 +1,7 @@ +-- Trac #1814 + +module ShouldFail where + +import Tcfail186_Help + +foo = f "hoo"
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/tcfail186.stderr b/testsuite/tests/typecheck/should_fail/tcfail186.stderr new file mode 100644 index 0000000000..3f4504b810 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail186.stderr @@ -0,0 +1,7 @@ + +tcfail186.hs:7:9: + Couldn't match expected type `PhantomSyn a0' + with actual type `[Char]' + In the first argument of `f', namely `"hoo"' + In the expression: f "hoo" + In an equation for `foo': foo = f "hoo" diff --git a/testsuite/tests/typecheck/should_fail/tcfail186.stderr-ghc-7.0 b/testsuite/tests/typecheck/should_fail/tcfail186.stderr-ghc-7.0 new file mode 100644 index 0000000000..737a0663ea --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail186.stderr-ghc-7.0 @@ -0,0 +1,7 @@ + +tcfail186.hs:7:9: + Couldn't match expected type `Int' with actual type `[Char]' + Expected type: PhantomSyn a0 + Actual type: [Char] + In the first argument of `f', namely `"hoo"' + In the expression: f "hoo" diff --git a/testsuite/tests/typecheck/should_fail/tcfail187.hs b/testsuite/tests/typecheck/should_fail/tcfail187.hs new file mode 100644 index 0000000000..eb508066ec --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail187.hs @@ -0,0 +1,7 @@ +-- Trac #1806 + +module ShouldFail where + +data Foo = (:::) + +foo (x ::: y) = () diff --git a/testsuite/tests/typecheck/should_fail/tcfail187.stderr b/testsuite/tests/typecheck/should_fail/tcfail187.stderr new file mode 100644 index 0000000000..07a741d025 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail187.stderr @@ -0,0 +1,5 @@ + +tcfail187.hs:7:6: + Constructor `:::' should have no arguments, but has been given 2 + In the pattern: x ::: y + In an equation for `foo': foo (x ::: y) = () diff --git a/testsuite/tests/typecheck/should_fail/tcfail188.hs b/testsuite/tests/typecheck/should_fail/tcfail188.hs new file mode 100644 index 0000000000..a79087d90d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail188.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE Rank2Types, KindSignatures #-} +{-# OPTIONS_GHC -Werror #-} + +-- Trac #959 + +module ShouldFail where + +data D (f :: (* -> *) -> * -> *) (af :: * -> *) (ax :: *) = + D (af (f af ax)) + +data CList (f :: (* -> *) -> * -> *) (a :: *) = + RCons a (CList (D f) a) + +type CycleList a = forall f. CList f a + +chead :: CycleList a -> a +chead ys = case ys of (RCons x xs) -> x diff --git a/testsuite/tests/typecheck/should_fail/tcfail188.stderr b/testsuite/tests/typecheck/should_fail/tcfail188.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail188.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail189.hs b/testsuite/tests/typecheck/should_fail/tcfail189.hs new file mode 100644 index 0000000000..3de16070c3 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail189.hs @@ -0,0 +1,11 @@ +-- Checks that the correct type is used checking the using clause of
+-- the group when a by clause is present
+
+{-# OPTIONS_GHC -XTransformListComp #-}
+
+module ShouldFail where
+
+foo = [ length x
+ | x <- [1..10]
+ , then group by x using take 2
+ ]
diff --git a/testsuite/tests/typecheck/should_fail/tcfail189.stderr b/testsuite/tests/typecheck/should_fail/tcfail189.stderr new file mode 100644 index 0000000000..b3a6cb4b96 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail189.stderr @@ -0,0 +1,8 @@ + +tcfail189.hs:10:31: + Couldn't match expected type `a -> t0' with actual type `[a0]' + Expected type: (a -> t0) -> [a] -> [[a]] + Actual type: [a0] -> [a0] + In the return type of a call of `take' + Probable cause: `take' is applied to too many arguments + In the expression: take 2 diff --git a/testsuite/tests/typecheck/should_fail/tcfail190.hs b/testsuite/tests/typecheck/should_fail/tcfail190.hs new file mode 100644 index 0000000000..7cc768af65 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail190.hs @@ -0,0 +1,13 @@ + +-- Checks that the ordering constraint on the implicit groupWith is respected + +{-# OPTIONS_GHC -XTransformListComp #-} + +module ShouldFail where + +data Unorderable = Gnorf | Pinky | Brain + +foo = [ () + | x <- [Gnorf, Brain] + , then group by x + ] diff --git a/testsuite/tests/typecheck/should_fail/tcfail190.stderr b/testsuite/tests/typecheck/should_fail/tcfail190.stderr new file mode 100644 index 0000000000..a2e1034162 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail190.stderr @@ -0,0 +1,8 @@ + +tcfail190.hs:12:9: + No instance for (Ord Unorderable) + arising from a use of `Control.Monad.Group.mgroupWith' + Possible fix: add an instance declaration for (Ord Unorderable) + In the expression: Control.Monad.Group.mgroupWith + In a stmt of a list comprehension: then group by x + In the expression: [() | x <- [Gnorf, Brain], then group by x] diff --git a/testsuite/tests/typecheck/should_fail/tcfail191.hs b/testsuite/tests/typecheck/should_fail/tcfail191.hs new file mode 100644 index 0000000000..e6553d07e2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail191.hs @@ -0,0 +1,12 @@ +-- Checks that the correct type is used checking the using clause of the group + +{-# OPTIONS_GHC -XTransformListComp #-} + +module ShouldFail where + +data Unorderable = Gnorf | Pinky | Brain + +foo = [ () + | x <- [Gnorf, Brain] + , then group using take 5 + ] diff --git a/testsuite/tests/typecheck/should_fail/tcfail191.stderr b/testsuite/tests/typecheck/should_fail/tcfail191.stderr new file mode 100644 index 0000000000..6fd626afd4 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail191.stderr @@ -0,0 +1,9 @@ + +tcfail191.hs:11:26: + Couldn't match type `a' with `[a]' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [[a]] at tcfail191.hs:11:9 + Expected type: [a] -> [[a]] + Actual type: [a] -> [a] + In the return type of a call of `take' + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/tcfail192.hs b/testsuite/tests/typecheck/should_fail/tcfail192.hs new file mode 100644 index 0000000000..15de576d91 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail192.hs @@ -0,0 +1,11 @@ +-- Checks that the types of the old binder and the binder
+-- implicitly introduced by grouping are linked
+
+{-# OPTIONS_GHC -XTransformListComp #-}
+
+module ShouldFail where
+
+foo = [ x + 1
+ | x <- ["Hello", "World"]
+ , then group using take 5
+ ]
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/tcfail192.stderr b/testsuite/tests/typecheck/should_fail/tcfail192.stderr new file mode 100644 index 0000000000..d72c821fd6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail192.stderr @@ -0,0 +1,18 @@ + +tcfail192.hs:8:13: + No instance for (Num [[Char]]) + arising from the literal `1' + Possible fix: add an instance declaration for (Num [[Char]]) + In the second argument of `(+)', namely `1' + In the expression: x + 1 + In the expression: + [x + 1 | x <- ["Hello", "World"], then group using take 5] + +tcfail192.hs:10:26: + Couldn't match type `a' with `[a]' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [[a]] at tcfail192.hs:10:9 + Expected type: [a] -> [[a]] + Actual type: [a] -> [a] + In the return type of a call of `take' + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/tcfail193.hs b/testsuite/tests/typecheck/should_fail/tcfail193.hs new file mode 100644 index 0000000000..f8bfd8f681 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail193.hs @@ -0,0 +1,11 @@ +-- Checks that the correct type is used checking the using clause of the transform
+
+{-# OPTIONS_GHC -XTransformListComp #-}
+
+module ShouldFail where
+
+import Data.List(inits)
+
+z :: [Int]
+z = [x | x <- [3, 2, 1], then inits]
+
diff --git a/testsuite/tests/typecheck/should_fail/tcfail193.stderr b/testsuite/tests/typecheck/should_fail/tcfail193.stderr new file mode 100644 index 0000000000..6fd99ae61b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail193.stderr @@ -0,0 +1,9 @@ + +tcfail193.hs:10:31: + Couldn't match type `a' with `[a]' + `a' is a rigid type variable bound by + a type expected by the context: [a] -> [a] at tcfail193.hs:10:26 + Expected type: [a] -> [a] + Actual type: [a] -> [[a]] + In the expression: inits + In a stmt of a list comprehension: then inits diff --git a/testsuite/tests/typecheck/should_fail/tcfail194.hs b/testsuite/tests/typecheck/should_fail/tcfail194.hs new file mode 100644 index 0000000000..9166b18b4a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail194.hs @@ -0,0 +1,10 @@ +-- Checks that using the "by" clause in a transform requires a function parameter + +{-# OPTIONS_GHC -XTransformListComp #-} + +module ShouldFail where + +import Data.List(take) + +z = [x | x <- [1..10], then take 5 by x] + diff --git a/testsuite/tests/typecheck/should_fail/tcfail194.stderr b/testsuite/tests/typecheck/should_fail/tcfail194.stderr new file mode 100644 index 0000000000..be6e37ec6b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail194.stderr @@ -0,0 +1,8 @@ + +tcfail194.hs:9:29: + Couldn't match expected type `a -> t0' with actual type `[a0]' + Expected type: (a -> t0) -> [a] -> [a] + Actual type: [a0] -> [a0] + In the return type of a call of `take' + Probable cause: `take' is applied to too many arguments + In the expression: take 5 diff --git a/testsuite/tests/typecheck/should_fail/tcfail195.hs b/testsuite/tests/typecheck/should_fail/tcfail195.hs new file mode 100644 index 0000000000..4c2408e8ba --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail195.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE RankNTypes, GADTs #-} + +module ShouldFail where + +data Foo a where + Foo :: Int -> Foo (forall a. a) diff --git a/testsuite/tests/typecheck/should_fail/tcfail195.stderr b/testsuite/tests/typecheck/should_fail/tcfail195.stderr new file mode 100644 index 0000000000..5816773f48 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail195.stderr @@ -0,0 +1,5 @@ + +tcfail195.hs:6:3: + Illegal polymorphic or qualified type: forall a. a + In the definition of data constructor `Foo' + In the data type declaration for `Foo' diff --git a/testsuite/tests/typecheck/should_fail/tcfail196.hs b/testsuite/tests/typecheck/should_fail/tcfail196.hs new file mode 100644 index 0000000000..a88f3c7f44 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail196.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} + +module ShouldFail where + +bar :: Num (forall a. a) => Int -> Int +bar = error "urk" + diff --git a/testsuite/tests/typecheck/should_fail/tcfail196.stderr b/testsuite/tests/typecheck/should_fail/tcfail196.stderr new file mode 100644 index 0000000000..79cc7266eb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail196.stderr @@ -0,0 +1,5 @@ +
+tcfail196.hs:5:1:
+ Illegal polymorphic or qualified type: forall a. a
+ In the type signature for `bar':
+ bar :: Num (forall a. a) => Int -> Int
diff --git a/testsuite/tests/typecheck/should_fail/tcfail197.hs b/testsuite/tests/typecheck/should_fail/tcfail197.hs new file mode 100644 index 0000000000..1aaffcd389 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail197.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} + +module ShouldFail where + +foo :: [forall a. a] -> Int +foo = error "urk" + diff --git a/testsuite/tests/typecheck/should_fail/tcfail197.stderr b/testsuite/tests/typecheck/should_fail/tcfail197.stderr new file mode 100644 index 0000000000..3abe57be7b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail197.stderr @@ -0,0 +1,6 @@ + +tcfail197.hs:5:1: + Illegal polymorphic or qualified type: forall a. a + Perhaps you intended to use -XImpredicativeTypes + In the type signature for `foo': + foo :: [forall a. a] -> Int diff --git a/testsuite/tests/typecheck/should_fail/tcfail198.hs b/testsuite/tests/typecheck/should_fail/tcfail198.hs new file mode 100644 index 0000000000..658545e9b2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail198.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +module ShouldFail where + +f3 :: forall a. [a] -> [a] +Just f3 = Just (\(x:xs) -> xs ++ [ x :: a ]) -- Not OK! + -- The type variable does not scope in a pattern binding diff --git a/testsuite/tests/typecheck/should_fail/tcfail198.stderr b/testsuite/tests/typecheck/should_fail/tcfail198.stderr new file mode 100644 index 0000000000..cc3ca54b14 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail198.stderr @@ -0,0 +1,9 @@ + +tcfail198.hs:6:17: + Couldn't match expected type `t0 -> t1' + with actual type `forall a. [a] -> [a]' + The lambda expression `\ (x : xs) -> xs ++ ...' has one argument, + but its type `forall a. [a] -> [a]' has none + In the first argument of `Just', namely + `(\ (x : xs) -> xs ++ [x :: a])' + In the expression: Just (\ (x : xs) -> xs ++ [x :: a]) diff --git a/testsuite/tests/typecheck/should_fail/tcfail199.hs b/testsuite/tests/typecheck/should_fail/tcfail199.hs new file mode 100644 index 0000000000..bf4dd6503d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail199.hs @@ -0,0 +1,5 @@ +-- trac #2179 + +module Main where + +main = "hi" diff --git a/testsuite/tests/typecheck/should_fail/tcfail199.stderr b/testsuite/tests/typecheck/should_fail/tcfail199.stderr new file mode 100644 index 0000000000..6866a26452 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail199.stderr @@ -0,0 +1,5 @@ + +tcfail199.hs:5:1: + Couldn't match expected type `IO t0' with actual type `[Char]' + In the expression: main + When checking the type of the function `main' diff --git a/testsuite/tests/typecheck/should_fail/tcfail200.hs b/testsuite/tests/typecheck/should_fail/tcfail200.hs new file mode 100644 index 0000000000..18d626207b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail200.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE MagicHash #-} + +module ShouldFail where + +f = let x = ( 1#, 'c' ) in x diff --git a/testsuite/tests/typecheck/should_fail/tcfail200.stderr b/testsuite/tests/typecheck/should_fail/tcfail200.stderr new file mode 100644 index 0000000000..90f590d8e2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail200.stderr @@ -0,0 +1,8 @@ + +tcfail200.hs:5:15: + Kind incompatibility when matching types: + t0 :: * + GHC.Prim.Int# :: # + In the expression: 1# + In the expression: (1#, 'c') + In an equation for `x': x = (1#, 'c') diff --git a/testsuite/tests/typecheck/should_fail/tcfail201.hs b/testsuite/tests/typecheck/should_fail/tcfail201.hs new file mode 100644 index 0000000000..276efd05ae --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail201.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE Rank2Types #-} + + +-- Claus reported by email that +-- GHCi, version 6.9.20080217 loops on this program +-- http://www.haskell.org/pipermail/cvs-ghc/2008-June/043173.html +-- So I'm adding it to the test suite so that we'll see it if it happens again + +module Foo where + +data HsDoc id + = DocEmpty + | DocParagraph (HsDoc id) + +gfoldl' :: (forall a b . c (a -> b) -> a -> c b) -> (forall g . g -> c g) -> a -> c a +gfoldl' k z hsDoc = case hsDoc of + DocEmpty -> z DocEmpty + (DocParagraph hsDoc) -> z DocParagraph `k` hsDoc + + + + + diff --git a/testsuite/tests/typecheck/should_fail/tcfail201.stderr b/testsuite/tests/typecheck/should_fail/tcfail201.stderr new file mode 100644 index 0000000000..653e503edc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail201.stderr @@ -0,0 +1,14 @@ + +tcfail201.hs:18:58: + Couldn't match type `a' with `HsDoc t0' + `a' is a rigid type variable bound by + the type signature for + gfoldl' :: (forall a1 b. c (a1 -> b) -> a1 -> c b) + -> (forall g. g -> c g) + -> a + -> c a + at tcfail201.hs:16:1 + Expected type: HsDoc t0 -> a + Actual type: HsDoc t0 -> HsDoc t0 + In the first argument of `z', namely `DocParagraph' + In the first argument of `k', namely `z DocParagraph' diff --git a/testsuite/tests/typecheck/should_fail/tcfail202.hs b/testsuite/tests/typecheck/should_fail/tcfail202.hs new file mode 100644 index 0000000000..7565755218 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail202.hs @@ -0,0 +1,13 @@ +-- trac #2307 +-- This was accepted due to a bug in GHC + +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + OverlappingInstances, UndecidableInstances, IncoherentInstances, + FlexibleInstances #-} + +module Foo where + +class C a b c | b -> c +instance C Bool Int Float +instance C Char Int Double + diff --git a/testsuite/tests/typecheck/should_fail/tcfail202.stderr b/testsuite/tests/typecheck/should_fail/tcfail202.stderr new file mode 100644 index 0000000000..a43f726580 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail202.stderr @@ -0,0 +1,7 @@ + +tcfail202.hs:11:10: + Functional dependencies conflict between instance declarations: + instance [incoherent] C Bool Int Float + -- Defined at tcfail202.hs:11:10-25 + instance [incoherent] C Char Int Double + -- Defined at tcfail202.hs:12:10-26 diff --git a/testsuite/tests/typecheck/should_fail/tcfail203.hs b/testsuite/tests/typecheck/should_fail/tcfail203.hs new file mode 100644 index 0000000000..7f51dae3b5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail203.hs @@ -0,0 +1,54 @@ +-- trac #2806 + +{-# LANGUAGE MagicHash, UnboxedTuples, BangPatterns #-} + +module Foo where + +import GHC.Base + +pass1 = 'a' + where !x = 5# + +pass2 = 'a' + where !(I# x) = 5 + +pass3 = 'a' + where !(b, I# x) = (True, 5) + +pass4 = 'a' + where !(# b, I# x #) = (# True, 5 #) + +pass5 = 'a' + where !(# b, x #) = (# True, 5# #) + +fail1 = 'a' + where x = 5# + +fail2 = 'a' + where (I# x) = 5 + +fail3 = 'a' + where (b, I# x) = (True, 5) + +fail4 = 'a' + where (# b, I# x #) = (# True, 5 #) + +fail5 = 'a' + where (# b, x #) = (# True, 5# #) + +fail6 = 'a' + where (I# !x) = 5 + +fail7 = 'a' + where (b, !(I# x)) = (True, 5) + +fail8 = 'a' + where (# b, !(I# x) #) = (# True, 5 #) + +fail9 = 'a' + where (# b, !x #) = (# True, 5# #) +{- +-- Now in tcfail203a.hs, because it's an error +fail10 = 'a' + where !(b, ~(c, (I# x))) = (True, (False, 5)) +-} diff --git a/testsuite/tests/typecheck/should_fail/tcfail203.stderr b/testsuite/tests/typecheck/should_fail/tcfail203.stderr new file mode 100644 index 0000000000..29cf84095b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail203.stderr @@ -0,0 +1,36 @@ + +tcfail203.hs:28:11: + Warning: Pattern bindings containing unlifted types should use an outermost bang pattern: + (I# x) = 5 + In an equation for `fail2': + fail2 + = 'a' + where + (I# x) = 5 + +tcfail203.hs:31:11: + Warning: Pattern bindings containing unlifted types should use an outermost bang pattern: + (b, I# x) = (True, 5) + In an equation for `fail3': + fail3 + = 'a' + where + (b, I# x) = (True, 5) + +tcfail203.hs:40:11: + Warning: Pattern bindings containing unlifted types should use an outermost bang pattern: + (I# !x) = 5 + In an equation for `fail6': + fail6 + = 'a' + where + (I# !x) = 5 + +tcfail203.hs:43:11: + Warning: Pattern bindings containing unlifted types should use an outermost bang pattern: + (b, !(I# x)) = (True, 5) + In an equation for `fail7': + fail7 + = 'a' + where + (b, !(I# x)) = (True, 5) diff --git a/testsuite/tests/typecheck/should_fail/tcfail203a.hs b/testsuite/tests/typecheck/should_fail/tcfail203a.hs new file mode 100644 index 0000000000..fd5ccaefbb --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail203a.hs @@ -0,0 +1,10 @@ +-- trac #2806 + +{-# LANGUAGE MagicHash, UnboxedTuples, BangPatterns #-} + +module Foo where + +import GHC.Base + +fail10 = 'a' + where !(b, ~(c, (I# x))) = (True, (False, 5)) diff --git a/testsuite/tests/typecheck/should_fail/tcfail203a.stderr b/testsuite/tests/typecheck/should_fail/tcfail203a.stderr new file mode 100644 index 0000000000..272ff4254e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail203a.stderr @@ -0,0 +1,6 @@ + +tcfail203a.hs:10:16: + A lazy (~) pattern cannot contain unlifted types: ~(c, (I# x)) + In the pattern: ~(c, (I# x)) + In the pattern: (b, ~(c, (I# x))) + In the pattern: !(b, ~(c, (I# x))) diff --git a/testsuite/tests/typecheck/should_fail/tcfail204.hs b/testsuite/tests/typecheck/should_fail/tcfail204.hs new file mode 100644 index 0000000000..ed561c3290 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail204.hs @@ -0,0 +1,11 @@ + +{-# OPTIONS_GHC -Wall #-} +{-# OPTIONS_GHC -Werror #-} + +-- Trac #3261 + +module Foo where + +foo :: Int +foo = ceiling 6.3 + diff --git a/testsuite/tests/typecheck/should_fail/tcfail204.stderr b/testsuite/tests/typecheck/should_fail/tcfail204.stderr new file mode 100644 index 0000000000..e9d9bb739d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail204.stderr @@ -0,0 +1,13 @@ + +tcfail204.hs:10:15: + Warning: Defaulting the following constraint(s) to type `Double' + (Fractional a0) arising from the literal `6.3' + at tcfail204.hs:10:15-17 + (RealFrac a0) arising from a use of `ceiling' + at tcfail204.hs:10:7-13 + In the first argument of `ceiling', namely `6.3' + In the expression: ceiling 6.3 + In an equation for `foo': foo = ceiling 6.3 + +<no location info>: +Failing due to -Werror. diff --git a/testsuite/tests/typecheck/should_fail/tcfail205.hs b/testsuite/tests/typecheck/should_fail/tcfail205.hs new file mode 100644 index 0000000000..6b676fbb78 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail205.hs @@ -0,0 +1,3 @@ +module Fail where + +f x = foldl (+) [1 .. x] 'a' diff --git a/testsuite/tests/typecheck/should_fail/tcfail205.stderr b/testsuite/tests/typecheck/should_fail/tcfail205.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail205.stderr diff --git a/testsuite/tests/typecheck/should_fail/tcfail206.hs b/testsuite/tests/typecheck/should_fail/tcfail206.hs new file mode 100644 index 0000000000..a256bc3e34 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail206.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE TupleSections, UnboxedTuples #-} +module Main where + +a :: Bool -> (Int, Bool) +a = ( , True) + +b :: Int -> Bool -> (Int, Bool) +b = (1, ) + +c :: a -> (a, Bool) +c = (True || False, ) + +d :: Bool -> (#Int, Bool#) +d = (# , True#) + +e :: Int -> Bool -> (#Int, Bool#) +e = (#1, #) + +f :: a -> (#a, Bool#) +f = (#True || False, #) + +main = return ()
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_fail/tcfail206.stderr b/testsuite/tests/typecheck/should_fail/tcfail206.stderr new file mode 100644 index 0000000000..46419c4522 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail206.stderr @@ -0,0 +1,46 @@ + +tcfail206.hs:5:5: + Couldn't match expected type `Int' with actual type `Bool' + Expected type: Bool -> (Int, Bool) + Actual type: Bool -> (Bool, t0) + In the expression: (, True) + In an equation for `a': a = (, True) + +tcfail206.hs:8:5: + Couldn't match expected type `Bool -> (Int, Bool)' + with actual type `(t0, Int)' + Expected type: Int -> Bool -> (Int, Bool) + Actual type: Int -> (t0, Int) + In the expression: (1,) + In an equation for `b': b = (1,) + +tcfail206.hs:11:6: + Couldn't match type `a' with `Bool' + `a' is a rigid type variable bound by + the type signature for c :: a -> (a, Bool) at tcfail206.hs:11:1 + In the expression: True || False + In the expression: (True || False,) + In an equation for `c': c = (True || False,) + +tcfail206.hs:14:5: + Couldn't match expected type `Int' with actual type `Bool' + Expected type: Bool -> (# Int, Bool #) + Actual type: Bool -> (# Bool, t0 #) + In the expression: (# , True #) + In an equation for `d': d = (# , True #) + +tcfail206.hs:17:5: + Couldn't match expected type `Bool -> (# Int, Bool #)' + with actual type `(# t0, Int #)' + Expected type: Int -> Bool -> (# Int, Bool #) + Actual type: Int -> (# t0, Int #) + In the expression: (# 1, #) + In an equation for `e': e = (# 1, #) + +tcfail206.hs:20:7: + Couldn't match type `a' with `Bool' + `a' is a rigid type variable bound by + the type signature for f :: a -> (# a, Bool #) at tcfail206.hs:20:1 + In the expression: True || False + In the expression: (# True || False, #) + In an equation for `f': f = (# True || False, #) diff --git a/testsuite/tests/typecheck/should_fail/tcfail207.hs b/testsuite/tests/typecheck/should_fail/tcfail207.hs new file mode 100644 index 0000000000..cd57f4892f --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail207.hs @@ -0,0 +1,9 @@ +module Foo where + +f :: Int -> [Int] -> [Int] +-- Want an error message that says 'take' is applied to too many args +f x = take x [] + +g :: [Int] +-- Want an error message that says 'take' is applied to too few args +g = take 3 diff --git a/testsuite/tests/typecheck/should_fail/tcfail207.stderr b/testsuite/tests/typecheck/should_fail/tcfail207.stderr new file mode 100644 index 0000000000..307b4044d5 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail207.stderr @@ -0,0 +1,16 @@ + +tcfail207.hs:5:7: + Couldn't match expected type `[Int] -> [Int]' + with actual type `[a0]' + In the return type of a call of `take' + Probable cause: `take' is applied to too many arguments + In the expression: take x [] + In an equation for `f': f x = take x [] + +tcfail207.hs:9:5: + Couldn't match expected type `[Int]' + with actual type `[a0] -> [a0]' + In the return type of a call of `take' + Probable cause: `take' is applied to too few arguments + In the expression: take 3 + In an equation for `g': g = take 3 diff --git a/testsuite/tests/typecheck/should_fail/tcfail208.hs b/testsuite/tests/typecheck/should_fail/tcfail208.hs new file mode 100644 index 0000000000..71c0f3c19b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail208.hs @@ -0,0 +1,5 @@ +module Ctx where + +f :: (Monad m, Eq a) => a -> m a -> Bool +f x y = (return x == y) + diff --git a/testsuite/tests/typecheck/should_fail/tcfail208.stderr b/testsuite/tests/typecheck/should_fail/tcfail208.stderr new file mode 100644 index 0000000000..64200a696d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/tcfail208.stderr @@ -0,0 +1,13 @@ + +tcfail208.hs:4:19: + Could not deduce (Eq (m a)) arising from a use of `==' + from the context (Monad m, Eq a) + bound by the type signature for + f :: (Monad m, Eq a) => a -> m a -> Bool + at tcfail208.hs:4:1-23 + Possible fix: + add (Eq (m a)) to the context of + the type signature for f :: (Monad m, Eq a) => a -> m a -> Bool + or add an instance declaration for (Eq (m a)) + In the expression: (return x == y) + In an equation for `f': f x y = (return x == y) |