diff --git a/ghc/tests/typecheck/Makefile b/ghc/tests/typecheck/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6d5951c7de2ffa87aa04604e063fb7d2b5f77110 --- /dev/null +++ b/ghc/tests/typecheck/Makefile @@ -0,0 +1,8 @@ +TOP = .. +include $(TOP)/mk/boilerplate.mk + +SUBDIRS = should_fail should_compile + +include $(TOP)/mk/target.mk + + diff --git a/ghc/tests/typecheck/should_compile/ClassFoo.hi b/ghc/tests/typecheck/should_compile/ClassFoo.hi new file mode 100644 index 0000000000000000000000000000000000000000..fbda08656dc47007bc089ec40430adfd4f69a3e8 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/ClassFoo.hi @@ -0,0 +1,5 @@ +_interface_ ClassFoo 1 +_exports_ +ClassFoo Foo(op1 op2); +_declarations_ +1 class Foo a where { op1 :: a -> PrelBase.Int; op2 :: a -> a -> PrelBase.Int} ; diff --git a/ghc/tests/typecheck/should_compile/M.hi b/ghc/tests/typecheck/should_compile/M.hi new file mode 100644 index 0000000000000000000000000000000000000000..ffb4e0c9dc8ffbe4edce57ecb239e64f82d43486 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/M.hi @@ -0,0 +1,4 @@ +interface M where +class (ORD a, Text a) => EQ a where (===) :: a -> a -> Bool +class (Num a) => ORD a +data NUM = ONE | TWO diff --git a/ghc/tests/typecheck/should_compile/Makefile b/ghc/tests/typecheck/should_compile/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..fc964d8676bfd0dbc7f1defd84270f10b372ab4e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/Makefile @@ -0,0 +1,19 @@ +TOP = ../../../.. +include $(TOP)/mk/boilerplate.mk + +HS_SRCS = $(wildcard *.hs) + +SRC_RUNTEST_OPTS += -o1 $*.stdout -o2 $*.stderr -x 0 +HC_OPTS += -noC -dcore-lint + +%.o : %.hs + $(RUNTEST) $(HC) $(RUNTEST_OPTS) -- $(HC_OPTS) -c $< -o $@ + +all :: $(HS_OBJS) + +tc019_HC_OPTS = -fglasgow-exts +tc065_HC_OPTS = -syslib ghc + +include $(TOP)/mk/target.mk + + diff --git a/ghc/tests/typecheck/should_compile/ShouldSucceed.hi b/ghc/tests/typecheck/should_compile/ShouldSucceed.hi new file mode 100644 index 0000000000000000000000000000000000000000..3ea8fd3a462a447adadefa36b42b4cec72fd9972 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/ShouldSucceed.hi @@ -0,0 +1,7 @@ +interface ShouldSucceed where { +{- TCE -} +{- CE -} +{- LVE -} +a :: Num t64 => t64 -> t64 +{- GIEinst -} +} diff --git a/ghc/tests/typecheck/should_compile/TheUtils.hi b/ghc/tests/typecheck/should_compile/TheUtils.hi new file mode 100644 index 0000000000000000000000000000000000000000..dd662cd3691dbff5007b5a05be3edc9030760078 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/TheUtils.hi @@ -0,0 +1,68 @@ +_interface_ TheUtils 2 +_instance_modules_ +ArrBase IO PrelNum +_usages_ +PrelBase 1 :: $d1 1 $d11 1 $d14 1 $d15 1 $d16 1 $d17 1 $d18 1 $d19 1 $d2 1 $d21 1 $d22 1 $d23 1 $d24 1 $d25 1 $d26 1 $d27 1 $d3 1 $d32 1 $d33 1 $d34 1 $d36 1 $d37 1 $d38 1 $d39 1 $d41 1 $d42 1 $d44 1 $d45 1 $d46 1 $d48 1 $d49 1 $d50 1 $d51 1 $d53 1 $d54 1 $d55 1 $d57 1 $d6 1 $d7 1 $d8 1 $m* 1 $m+ 1 $m++ 1 $m- 1 $m/= 1 $m< 1 $m<= 1 $m== 1 $m> 1 $m>= 1 $m>> 1 $m>>= 1 $mabs 1 $mcompare 1 $mfromInt 1 $mfromInteger 1 $mmap 1 $mmax 1 $mmin 1 $mnegate 1 $mreturn 1 $mshowList 1 $mshowsPrec 1 $msignum 1 $mzero 1 && 1 . 1 not 1 otherwise 1 show 1 || 1 Eq 1 Eval 1 Functor 1 Maybe 1 Monad 1 MonadPlus 1 MonadZero 1 Num 1 Ord 1 Ordering 1 Ordering 1 Show 1 String 1; +PrelList 1 :: repeat 1 reverse 1 span 1 take 1; +PrelNum 1 :: $d10 1 $d16 1 $d17 1 $d18 1 $d29 1 $d33 1 $d34 1 $d35 1; +PrelTup 1 :: $d10 1 $d13 1 $d14 1 $d3 1 $d4 1 $d49 1 $d50 1 $d9 1; +Pretty 1 :: $d1 1 $d2 1 hsep 1 int 1 sep 1 text 1 Doc 1; +_exports_ +TheUtils appEager assertPanic assertPprPanic assoc assocDefault assocDefaultUsing assocUsing cmpList cmpPString endsWith equivClasses hasNoDups isIn isSingleton isn'tIn lengthExceeds mapAccumB mapAccumL mapAccumR mapAndUnzip mapAndUnzip3 mapEager nOfThem naturalMergeSortLe panic panic# pprError pprPanic pprPanic# pprTrace removeDups returnEager runEager runs sortLt startsWith thenCmp thenEager transitiveClosure unzipWith zipEqual zipLazy zipWith3Equal zipWith4Equal zipWithEqual Eager Ord3(cmp); +_fixities_ +infixr 9 thenCmp; +_instances_ +instance {Ord3 PrelBase.Int} = $d1; +instance _forall_ [a] {Ord3 a} => {Ord3 (PrelBase.Maybe a)} = $d2; +instance _forall_ [a] {Ord3 a} => {Ord3 [a]} = $d3; +_declarations_ +2 $d1 _:_ {Ord3 PrelBase.Int} ;; +1 $d2 _:_ _forall_ [a] {Ord3 a} => {Ord3 (PrelBase.Maybe a)} ;; +1 $d3 _:_ _forall_ [a] {Ord3 a} => {Ord3 [a]} ;; +1 $mcmp _:_ _forall_ [a] {Ord3 a} => a -> a -> GHC.Int# ;; +2 type Eager rvB rvC = (rvC -> rvB) -> rvB ; +2 class Ord3 rvx where {cmp :: rvx -> rvx -> GHC.Int#} ; +1 appEager _:_ _forall_ [a b] => Eager b a -> (a -> b) -> b ;; +1 assertPanic _:_ _forall_ [a] => PrelBase.String -> PrelBase.Int -> a ;; +2 assertPprPanic _:_ _forall_ [a] => PrelBase.String -> PrelBase.Int -> Pretty.Doc -> a ;; +1 assoc _:_ _forall_ [a b] {PrelBase.Eq a} => PrelBase.String -> [(a, b)] -> a -> b ;; +1 assocDefault _:_ _forall_ [a b] {PrelBase.Eq a} => b -> [(a, b)] -> a -> b ;; +1 assocDefaultUsing _:_ _forall_ [a b] => (a -> a -> PrelBase.Bool) -> b -> [(a, b)] -> a -> b ;; +1 assocUsing _:_ _forall_ [a b] => (a -> a -> PrelBase.Bool) -> PrelBase.String -> [(a, b)] -> a -> b ;; +1 cmpList _:_ _forall_ [a] => (a -> a -> GHC.Int#) -> [a] -> [a] -> GHC.Int# ;; +1 endsWith _:_ PrelBase.String -> PrelBase.String -> PrelBase.Maybe PrelBase.String ;; +1 equivClasses _:_ _forall_ [a] => (a -> a -> GHC.Int#) -> [a] -> [[a]] ;; +1 hasNoDups _:_ _forall_ [a] {PrelBase.Eq a} => [a] -> PrelBase.Bool ;; +1 isIn _:_ _forall_ [a] {PrelBase.Eq a} => PrelBase.String -> a -> [a] -> PrelBase.Bool ;; +1 isSingleton _:_ _forall_ [a] => [a] -> PrelBase.Bool ;; +1 isn'tIn _:_ _forall_ [a] {PrelBase.Eq a} => PrelBase.String -> a -> [a] -> PrelBase.Bool ;; +1 lengthExceeds _:_ _forall_ [a] => [a] -> PrelBase.Int -> PrelBase.Bool ;; +1 mapAccumB _:_ _forall_ [a b c d] => (b -> c -> a -> (b, c, d)) -> b -> c -> [a] -> (b, c, [d]) ;; +1 mapAccumL _:_ _forall_ [a b c] => (b -> a -> (b, c)) -> b -> [a] -> (b, [c]) ;; +1 mapAccumR _:_ _forall_ [a b c] => (b -> a -> (b, c)) -> b -> [a] -> (b, [c]) ;; +1 mapAndUnzip _:_ _forall_ [a b c] => (a -> (b, c)) -> [a] -> ([b], [c]) ;; +1 mapAndUnzip3 _:_ _forall_ [a b c d] => (a -> (b, c, d)) -> [a] -> ([b], [c], [d]) ;; +1 mapEager _:_ _forall_ [a b c] => (a -> (c -> b) -> b) -> [a] -> ([c] -> b) -> b ;; +1 nOfThem _:_ _forall_ [a] => PrelBase.Int -> a -> [a] ;; +1 naturalMergeSortLe _:_ _forall_ [a] => (a -> a -> PrelBase.Bool) -> [a] -> [a] ;; +1 panic _:_ _forall_ [a] => [PrelBase.Char] -> a ;; +1 panic# _:_ PrelBase.String -> GHC.Int# ;; +1 pprError _:_ _forall_ [a b] {PrelBase.Show a} => [PrelBase.Char] -> a -> b ;; +1 pprPanic _:_ _forall_ [a b] {PrelBase.Show a} => [PrelBase.Char] -> a -> b ;; +1 pprPanic# _:_ _forall_ [a] {PrelBase.Show a} => [PrelBase.Char] -> a -> GHC.Int# ;; +1 pprTrace _:_ _forall_ [a b] {PrelBase.Show a} => [PrelBase.Char] -> a -> b -> b ;; +1 removeDups _:_ _forall_ [a] => (a -> a -> GHC.Int#) -> [a] -> ([a], [[a]]) ;; +1 returnEager _:_ _forall_ [a b] => b -> (b -> a) -> a ;; +1 runEager _:_ _forall_ [a] => Eager a a -> a ;; +1 runs _:_ _forall_ [a] => (a -> a -> PrelBase.Bool) -> [a] -> [[a]] ;; +1 sortLt _:_ _forall_ [a] => (a -> a -> PrelBase.Bool) -> [a] -> [a] ;; +1 startsWith _:_ PrelBase.String -> PrelBase.String -> PrelBase.Maybe PrelBase.String ;; +1 thenCmp _:_ GHC.Int# -> GHC.Int# -> GHC.Int# ;; +1 thenEager _:_ _forall_ [a b c] => Eager b a -> (a -> (c -> b) -> b) -> (c -> b) -> b ;; +1 transitiveClosure _:_ _forall_ [a] => (a -> [a]) -> (a -> a -> PrelBase.Bool) -> [a] -> [a] ;; +1 unzipWith _:_ _forall_ [a b c] => (a -> b -> c) -> [(a, b)] -> [c] ;; +1 zipEqual _:_ _forall_ [a b] => PrelBase.String -> [a] -> [b] -> [(a, b)] ;; +1 zipLazy _:_ _forall_ [a b] => [a] -> [b] -> [(a, b)] ;; +1 zipWith3Equal _:_ _forall_ [a b c d] => PrelBase.String -> (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] ;; +1 zipWith4Equal _:_ _forall_ [a b c d e] => PrelBase.String -> (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e] ;; +1 zipWithEqual _:_ _forall_ [a b c] => PrelBase.String -> (a -> b -> c) -> [a] -> [b] -> [c] ;; diff --git a/ghc/tests/typecheck/should_compile/tc001.hs b/ghc/tests/typecheck/should_compile/tc001.hs new file mode 100644 index 0000000000000000000000000000000000000000..c3b0a785e26ed22afae9ba8fc8ac7924f6a1d890 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc001.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +a x = y+2 where y = x+3 diff --git a/ghc/tests/typecheck/should_compile/tc002.hs b/ghc/tests/typecheck/should_compile/tc002.hs new file mode 100644 index 0000000000000000000000000000000000000000..85f1a91e1fc5b10eadb03ed3c01cd7bdbfa7929e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc002.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +b = if True then 1 else 2 diff --git a/ghc/tests/typecheck/should_compile/tc003.hs b/ghc/tests/typecheck/should_compile/tc003.hs new file mode 100644 index 0000000000000000000000000000000000000000..70459c34434e8f384be1ea391dbc02cbe7527ed6 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc003.hs @@ -0,0 +1,12 @@ +module ShouldSucceed where + +-- This is a somewhat surprising program. +-- It shows up the monomorphism restriction, *and* ambiguity resolution! +-- The binding is a pattern binding without a signature, so it is monomorphic. +-- Hence the types of c,d,e are not universally quantified. But then +-- their type variables are ambiguous, so the ambiguity resolution leaps +-- into action, and resolves them to Integer. + +-- That's why we check the interface file in the test suite. + +(c@(d,e)) = if True then (1,2) else (1,3) diff --git a/ghc/tests/typecheck/should_compile/tc004.hs b/ghc/tests/typecheck/should_compile/tc004.hs new file mode 100644 index 0000000000000000000000000000000000000000..a0627302d4260c96b6edb7da4aa6666fb46f0f6f --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc004.hs @@ -0,0 +1,5 @@ +module ShouldSucceed where + +f x = case x of + True -> True + False -> x diff --git a/ghc/tests/typecheck/should_compile/tc005.hs b/ghc/tests/typecheck/should_compile/tc005.hs new file mode 100644 index 0000000000000000000000000000000000000000..9d39da891272b17d3d40f3907648ff590fb72417 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc005.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +g ((x:z),y) = x +g (x,y) = 2 diff --git a/ghc/tests/typecheck/should_compile/tc006.hs b/ghc/tests/typecheck/should_compile/tc006.hs new file mode 100644 index 0000000000000000000000000000000000000000..2a22688d197dfdec32ece11b16db1ae5e64093a2 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc006.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +h = 1:h diff --git a/ghc/tests/typecheck/should_compile/tc007.hs b/ghc/tests/typecheck/should_compile/tc007.hs new file mode 100644 index 0000000000000000000000000000000000000000..c65458514bc8a26ac75b67a0c269d49a8b3b56b0 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc007.hs @@ -0,0 +1,9 @@ +module ShouldSucceed where + +j = 2 + +k = 1:j:l + +l = 0:k + +m = j+j diff --git a/ghc/tests/typecheck/should_compile/tc008.hs b/ghc/tests/typecheck/should_compile/tc008.hs new file mode 100644 index 0000000000000000000000000000000000000000..236b575573e08f2dcefbe0432ba1a5f11731a52a --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc008.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +n True = 1 +n False = 0 diff --git a/ghc/tests/typecheck/should_compile/tc009.hs b/ghc/tests/typecheck/should_compile/tc009.hs new file mode 100644 index 0000000000000000000000000000000000000000..b682a94c0d224f7950508ae6c4db46be80fb6a61 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc009.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +o (True,x) = x +o (False,y) = y+1 diff --git a/ghc/tests/typecheck/should_compile/tc010.hs b/ghc/tests/typecheck/should_compile/tc010.hs new file mode 100644 index 0000000000000000000000000000000000000000..8ec9afd3d0e78e7e1f4338b4e4596ebc917d8511 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc010.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +p = [(y+2,True) | y <- [1,2]] diff --git a/ghc/tests/typecheck/should_compile/tc011.hs b/ghc/tests/typecheck/should_compile/tc011.hs new file mode 100644 index 0000000000000000000000000000000000000000..24c5b3b91b344373de24dd6562fe73ea39d9ef77 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc011.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +x@_ = x diff --git a/ghc/tests/typecheck/should_compile/tc012.hs b/ghc/tests/typecheck/should_compile/tc012.hs new file mode 100644 index 0000000000000000000000000000000000000000..6f5e9542204245244594b568536bc875c39ee511 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc012.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +q = \ y -> y diff --git a/ghc/tests/typecheck/should_compile/tc013.hs b/ghc/tests/typecheck/should_compile/tc013.hs new file mode 100644 index 0000000000000000000000000000000000000000..f6a08b5e7b68130fb18cad4d9d5ef5dd114b7d28 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc013.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +(r,s) = (1,'a') diff --git a/ghc/tests/typecheck/should_compile/tc014.hs b/ghc/tests/typecheck/should_compile/tc014.hs new file mode 100644 index 0000000000000000000000000000000000000000..97ce37558351b6356d77190dada67e6561a458d7 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc014.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +t = 1+t diff --git a/ghc/tests/typecheck/should_compile/tc015.hs b/ghc/tests/typecheck/should_compile/tc015.hs new file mode 100644 index 0000000000000000000000000000000000000000..41c902bfc6b56a338036d0bc3b4f88a897be2877 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc015.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +u x = \ (y,z) -> x diff --git a/ghc/tests/typecheck/should_compile/tc016.hs b/ghc/tests/typecheck/should_compile/tc016.hs new file mode 100644 index 0000000000000000000000000000000000000000..5f3c7e57215f016151f806f03af383b3ce60e906 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc016.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +f x@_ y@_ = x diff --git a/ghc/tests/typecheck/should_compile/tc017.hs b/ghc/tests/typecheck/should_compile/tc017.hs new file mode 100644 index 0000000000000000000000000000000000000000..ec51aeb8d0b385b00566816584acd970d5dd6b89 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc017.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +v | True = v+1 + | False = v diff --git a/ghc/tests/typecheck/should_compile/tc018.hs b/ghc/tests/typecheck/should_compile/tc018.hs new file mode 100644 index 0000000000000000000000000000000000000000..7fb398c6e65115832536c0081b0daf2d349de0b8 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc018.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +w = a where a = y + y = 2 diff --git a/ghc/tests/typecheck/should_compile/tc019.hs b/ghc/tests/typecheck/should_compile/tc019.hs new file mode 100644 index 0000000000000000000000000000000000000000..3cfe5ea62699a673848ec7cfd0d4ff2f721c4b0c --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc019.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +(al:am) = [y+1 | (y,z) <- [(1,2)]] diff --git a/ghc/tests/typecheck/should_compile/tc020.hs b/ghc/tests/typecheck/should_compile/tc020.hs new file mode 100644 index 0000000000000000000000000000000000000000..a0ef679c8fc93c029737cea1f8ee0194427aa9c0 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc020.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +f x = a where a = x:a diff --git a/ghc/tests/typecheck/should_compile/tc021.hs b/ghc/tests/typecheck/should_compile/tc021.hs new file mode 100644 index 0000000000000000000000000000000000000000..418fa38e2918599cf86e4b26eabf4eb34d975257 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc021.hs @@ -0,0 +1,7 @@ +module ShouldSucceed where + +f x = a + +a = (x,x) + +x = x diff --git a/ghc/tests/typecheck/should_compile/tc022.hs b/ghc/tests/typecheck/should_compile/tc022.hs new file mode 100644 index 0000000000000000000000000000000000000000..1a04d7e7a28be4fb5b831cd28f0d53eb417245d4 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc022.hs @@ -0,0 +1,5 @@ +module ShouldSucceed where + +main = iD iD + +iD x = x diff --git a/ghc/tests/typecheck/should_compile/tc023.hs b/ghc/tests/typecheck/should_compile/tc023.hs new file mode 100644 index 0000000000000000000000000000000000000000..b996719bb9bcc6165aee8eb0f92066a5a0220437 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc023.hs @@ -0,0 +1,7 @@ +module ShouldSucceed where + +main = s k k + +s f g x = f x (g x) + +k x y = x diff --git a/ghc/tests/typecheck/should_compile/tc024.hs b/ghc/tests/typecheck/should_compile/tc024.hs new file mode 100644 index 0000000000000000000000000000000000000000..e28d1acf96c827e8577479b5d27ce7eaeb03e0ab --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc024.hs @@ -0,0 +1,7 @@ +module ShouldSucceed where + +main x = s k k x + +s f g x = f x (g x) + +k x y = x diff --git a/ghc/tests/typecheck/should_compile/tc025.hs b/ghc/tests/typecheck/should_compile/tc025.hs new file mode 100644 index 0000000000000000000000000000000000000000..e9adf9acb5713e387877dae7251ec697ff70219c --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc025.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +g x = f (f True x) x where f x y = if x then y else (f x y) diff --git a/ghc/tests/typecheck/should_compile/tc026.hs b/ghc/tests/typecheck/should_compile/tc026.hs new file mode 100644 index 0000000000000000000000000000000000000000..3e718a5053a541c4edcfc0ff2891c8f8e9015e46 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc026.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +g x = f (f True x) x +f x y = if x then y else (f x y) diff --git a/ghc/tests/typecheck/should_compile/tc027.hs b/ghc/tests/typecheck/should_compile/tc027.hs new file mode 100644 index 0000000000000000000000000000000000000000..6edc01b619fc0154b767f4f787698407d9505ad4 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc027.hs @@ -0,0 +1,5 @@ +module ShouldSucceed where + +h x = f (f True x) x +f x y = if x then y else (g y x) +g y x = if x then y else (f x y) diff --git a/ghc/tests/typecheck/should_compile/tc028.hs b/ghc/tests/typecheck/should_compile/tc028.hs new file mode 100644 index 0000000000000000000000000000000000000000..49a0835ade2708803ec6bc34aa5af23f46be3b34 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc028.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +type H = (Int,Bool) diff --git a/ghc/tests/typecheck/should_compile/tc029.hs b/ghc/tests/typecheck/should_compile/tc029.hs new file mode 100644 index 0000000000000000000000000000000000000000..c44b78f79f1fc3ae1b588589aee90e67f395d2d7 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc029.hs @@ -0,0 +1,6 @@ +module ShouldSucceed where + +type G = [Int] + +data K = H Bool | M G + diff --git a/ghc/tests/typecheck/should_compile/tc030.hs b/ghc/tests/typecheck/should_compile/tc030.hs new file mode 100644 index 0000000000000000000000000000000000000000..004bc226d1ff29c3da0d869601ae9a5e508b37de --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc030.hs @@ -0,0 +1,5 @@ +module ShouldSucceed where + +type H = [Bool] + +type G = (H,Char) diff --git a/ghc/tests/typecheck/should_compile/tc031.hs b/ghc/tests/typecheck/should_compile/tc031.hs new file mode 100644 index 0000000000000000000000000000000000000000..c55bf11f54096f1622492f623067bb5531238607 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc031.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +data Rec = Node Int Rec diff --git a/ghc/tests/typecheck/should_compile/tc032.hs b/ghc/tests/typecheck/should_compile/tc032.hs new file mode 100644 index 0000000000000000000000000000000000000000..9c43bbb0100d890c5203dcaf3789763bd5476392 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc032.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +data AList b = Node b [b] | Other (b,Char) diff --git a/ghc/tests/typecheck/should_compile/tc033.hs b/ghc/tests/typecheck/should_compile/tc033.hs new file mode 100644 index 0000000000000000000000000000000000000000..7111d75a4eea04d3271cab22ee2dccd3a02594c1 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc033.hs @@ -0,0 +1,7 @@ +module ShouldSucceed where + +data Twine = Twine2 Twist + +data Twist = Twist2 Twine + +type F = Twine diff --git a/ghc/tests/typecheck/should_compile/tc034.hs b/ghc/tests/typecheck/should_compile/tc034.hs new file mode 100644 index 0000000000000000000000000000000000000000..0e7c4a66ed995d2c5b9101dd37b565181920b197 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc034.hs @@ -0,0 +1,11 @@ +module ShouldSucceed where + +data AList a = ANull | ANode a (AList a) + +type IntList = AList Int + +g (ANull) = 2 +g (ANode b (ANode c d)) | b = 3 + | True = 4 + + diff --git a/ghc/tests/typecheck/should_compile/tc035.hs b/ghc/tests/typecheck/should_compile/tc035.hs new file mode 100644 index 0000000000000000000000000000000000000000..b8dd5543736d46b4f588985d6174bbc0f4ebfa0d --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc035.hs @@ -0,0 +1,9 @@ +module ShouldSucceed where + +type AnnExpr a = (a,Expr a) + +data Expr a = Var [Char] + | App (AnnExpr a) (AnnExpr a) + +g (a,(Var name)) = [name] +g (a,(App e1 e2)) = (g e1) ++ (g e2) diff --git a/ghc/tests/typecheck/should_compile/tc036.hs b/ghc/tests/typecheck/should_compile/tc036.hs new file mode 100644 index 0000000000000000000000000000000000000000..05b87846aca15ed96e1d567bccc314420c57fe56 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc036.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +class (Eq a) => A a where + op1 :: a -> a diff --git a/ghc/tests/typecheck/should_compile/tc037.hi b/ghc/tests/typecheck/should_compile/tc037.hi new file mode 100644 index 0000000000000000000000000000000000000000..026e6c2b5cd8e9c104ba616a3541a21628ffcba2 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc037.hi @@ -0,0 +1,6 @@ +interface ShouldSucceed where { +class Eq' a where { + deq :: a -> a -> Bool + }; +instance (Eq' a) => Eq' [a] {-# FROMMODULE ShouldSucceed #-} +} diff --git a/ghc/tests/typecheck/should_compile/tc037.hs b/ghc/tests/typecheck/should_compile/tc037.hs new file mode 100644 index 0000000000000000000000000000000000000000..8621b278d32e4da8bf04514aea367b0cc44f009e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc037.hs @@ -0,0 +1,9 @@ +module ShouldSucceed where + +class Eq' a where + deq :: a -> a -> Bool + +instance (Eq' a) => Eq' [a] where + deq [] [] = True + deq (x:xs) (y:ys) = if (x `deq` y) then (deq xs ys) else False + deq other1 other2 = False diff --git a/ghc/tests/typecheck/should_compile/tc038.hs b/ghc/tests/typecheck/should_compile/tc038.hs new file mode 100644 index 0000000000000000000000000000000000000000..d404ee69132bb3ced15488a80b33b9630ac21c7e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc038.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +f (x:xs) = if (x == (fromInteger 2)) then xs else [] diff --git a/ghc/tests/typecheck/should_compile/tc039.hs b/ghc/tests/typecheck/should_compile/tc039.hs new file mode 100644 index 0000000000000000000000000000000000000000..0e5bd9518cebd20ccc9f8f7fbfd3256527f6adc0 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc039.hs @@ -0,0 +1,4 @@ +module ShouldSucc where + +class (Eq a) => A a where + op1 :: a -> a diff --git a/ghc/tests/typecheck/should_compile/tc040.hi b/ghc/tests/typecheck/should_compile/tc040.hi new file mode 100644 index 0000000000000000000000000000000000000000..41d1ee57b36dedae5cc64bb61e3547bbf543bf19 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc040.hi @@ -0,0 +1,4 @@ +interface ShouldSucceed where { +import PreludeCore(Eq) +f :: Eq a => a -> [a] +} diff --git a/ghc/tests/typecheck/should_compile/tc040.hs b/ghc/tests/typecheck/should_compile/tc040.hs new file mode 100644 index 0000000000000000000000000000000000000000..33113cc07d79899897db6cbd4d920ded7f0b1fdc --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc040.hs @@ -0,0 +1,9 @@ +module ShouldSucceed where + +--!!! tests the deduction of contexts. + +f :: (Eq a) => a -> [a] + +f x = g x + where + g y = if (y == x) then [] else [y] diff --git a/ghc/tests/typecheck/should_compile/tc041.hs b/ghc/tests/typecheck/should_compile/tc041.hs new file mode 100644 index 0000000000000000000000000000000000000000..730af9c1aec0705b24245424b8da964407f81bb8 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc041.hs @@ -0,0 +1,12 @@ +--!!! a very simple test of class and instance declarations + +module ShouldSucceed where + +class H a where + op1 :: a -> a -> a + +instance H Bool where + op1 x y = y + +f :: Bool -> Int -> Bool +f x y = op1 x x diff --git a/ghc/tests/typecheck/should_compile/tc042.hs b/ghc/tests/typecheck/should_compile/tc042.hs new file mode 100644 index 0000000000000000000000000000000000000000..708ea26d67fedc287bedba6a435df5730a3f3a20 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc042.hs @@ -0,0 +1,73 @@ +--!!! a file mailed us by Ryzard Kubiak. This provides a good test of the code +--!!! handling type signatures and recursive data types. + +module ShouldSucceed where + +data Boolean = FF | TT +data Pair a b = Mkpair a b +data List alpha = Nil | Cons alpha (List alpha) +data Nat = Zero | Succ Nat +data Tree t = Leaf t | Node (Tree t) (Tree t) + +idb :: Boolean -> Boolean +idb x = x + + +swap :: Pair a b -> Pair b a +swap t = case t of + Mkpair x y -> Mkpair y x + +neg :: Boolean -> Boolean +neg b = case b of + FF -> TT + TT -> FF + +nUll :: List alpha -> Boolean +nUll l = case l of + Nil -> TT + Cons y ys -> FF + +idl :: List a -> List a +idl xs = case xs of + Nil -> Nil + Cons y ys -> Cons y (idl ys) + +add :: Nat -> Nat -> Nat +add a b = case a of + Zero -> b + Succ c -> Succ (add c b) + +app :: List alpha -> List alpha -> List alpha +app xs zs = case xs of + Nil -> zs + Cons y ys -> Cons y (app ys zs) + +lEngth :: List a -> Nat +lEngth xs = case xs of + Nil -> Zero + Cons y ys -> Succ(lEngth ys) + +before :: List Nat -> List Nat +before xs = case xs of + Nil -> Nil + Cons y ys -> case y of + Zero -> Nil + Succ n -> Cons y (before ys) + +rEverse :: List alpha -> List alpha +rEverse rs = case rs of + Nil -> Nil + Cons y ys -> app (rEverse ys) (Cons y Nil) + + +flatten :: Tree alpha -> List alpha +flatten t = case t of + Leaf x -> Cons x Nil + Node l r -> app (flatten l) (flatten r) + +sUm :: Tree Nat -> Nat +sUm t = case t of + Leaf t -> t + Node l r -> add (sUm l) (sUm r) + + diff --git a/ghc/tests/typecheck/should_compile/tc043.hs b/ghc/tests/typecheck/should_compile/tc043.hs new file mode 100644 index 0000000000000000000000000000000000000000..727f2886aeec0134433b038c1b3765863b99f990 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc043.hs @@ -0,0 +1,18 @@ +module ShouldSucceed where + +--!!! another simple test of class and instance code. + +class A a where + op1 :: a + +instance A Int where + op1 = 2 + +f x = op1 + +class B b where + op2 :: b -> Int + +instance (B a) => B [a] where + op2 [] = 0 + op2 (x:xs) = 1 + op2 xs diff --git a/ghc/tests/typecheck/should_compile/tc044.hs b/ghc/tests/typecheck/should_compile/tc044.hs new file mode 100644 index 0000000000000000000000000000000000000000..9f98989bb11695d584aff99474db5652e4f3db34 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc044.hs @@ -0,0 +1,6 @@ +-- once produced a bug, here as regression test + +module P where + +f _ | otherwise = () + diff --git a/ghc/tests/typecheck/should_compile/tc045.hs b/ghc/tests/typecheck/should_compile/tc045.hs new file mode 100644 index 0000000000000000000000000000000000000000..fc6a72ea979aa66daf7efbb137feccb0f01cf6f3 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc045.hs @@ -0,0 +1,19 @@ +module H 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 + +instance C [a] where + op1 xs = xs + +{- This was passed by the prototype, but failed hard in the new +typechecker with the message + +Fail:No match in theta_class +-} diff --git a/ghc/tests/typecheck/should_compile/tc046.hs b/ghc/tests/typecheck/should_compile/tc046.hs new file mode 100644 index 0000000000000000000000000000000000000000..dbbf3a176a5ac1eba86875daaebdbf2b1880dfa3 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc046.hs @@ -0,0 +1,9 @@ +module H where + +class C a where + op1 :: a -> a + +class (C a) => B a where + op2 :: a -> a -> a + +{- Failed hard in new tc with "No match in theta_class" -} diff --git a/ghc/tests/typecheck/should_compile/tc047.hs b/ghc/tests/typecheck/should_compile/tc047.hs new file mode 100644 index 0000000000000000000000000000000000000000..b8c197d185f09f42eb3d48e1d32247a5a30499d3 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc047.hs @@ -0,0 +1,23 @@ +module ShouldSucceed where + +type OL a = [a] + +-- produces the interface: +-- data OL a = MkOL [a] deriving () +-- ranOAL :: (OL (a, a)) -> [a] +-- this interface was produced by BOTH hbc and nhc + +-- the following bogus type sig. was accepted by BOTH hbc and nhc +f x = ranOAL where -- ranOAL :: OL (a,v) -> [a] +--ranOAL :: OL (a,v) -> [v], the right sig. + ranOAL ( xs) = mp sd xs + + +mp f [] = [] +mp f (x:xs) = (f x) : mp f xs + +sd (f,s) = s + + + + diff --git a/ghc/tests/typecheck/should_compile/tc048.hs b/ghc/tests/typecheck/should_compile/tc048.hs new file mode 100644 index 0000000000000000000000000000000000000000..eea6f10e791a776760b9b83b5245e1da7715abae --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc048.hs @@ -0,0 +1,21 @@ +module ShouldSucceed where + +data OL a = MkOL [a] +data FG a b = MkFG (OL (a,b)) +data AFE n a b = MkAFE (OL (n,(FG a b))) + +--ranOAL :: OL (a,v) -> [a] +ranOAL :: OL (a,v) -> [v] +ranOAL (MkOL xs) = mAp sNd xs + +mAp f [] = [] +mAp f (x:xs) = (f x) : mAp f xs + +sNd (f,s) = s + +ranAFE :: AFE n a b -> [FG a b] -- ? +ranAFE (MkAFE nfs) = ranOAL nfs + + + + diff --git a/ghc/tests/typecheck/should_compile/tc049.hs b/ghc/tests/typecheck/should_compile/tc049.hs new file mode 100644 index 0000000000000000000000000000000000000000..20be6b768b3cc11db8d7c34c6f42e8be17b1400f --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc049.hs @@ -0,0 +1,39 @@ +module ShouldSucceed where + +fib n = if n <= 2 then n else fib (n-1) + fib (n-2) + +---------------------------------------- + +mem x [] = False +mem x (y:ys) = (x == y) `oR` mem x ys + +a `oR` b = if a then True else b + +---------------------------------------- + +mem1 x [] = False +mem1 x (y:ys) = (x == y) `oR1` mem2 x ys + +a `oR1` b = if a then True else b + +mem2 x [] = False +mem2 x (y:ys) = (x == y) `oR` mem1 x ys + +--------------------------------------- + +mem3 x [] = False +mem3 x (y:ys) = if [x] == [y] then mem4 x ys else False + +mem4 y (x:xs) = mem3 y xs + +--------------------------------------- + +main1 = [[(1,True)]] == [[(2,False)]] + +--------------------------------------- + +main2 = "Hello" == "Goodbye" + +--------------------------------------- + +main3 = [[1],[2]] == [[3]] diff --git a/ghc/tests/typecheck/should_compile/tc050.hs b/ghc/tests/typecheck/should_compile/tc050.hs new file mode 100644 index 0000000000000000000000000000000000000000..ef03b282d908116441dd2911d3f2a41b9892171e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc050.hs @@ -0,0 +1,23 @@ +module ShouldSucceed where + +class Foo a where + o_and :: a -> a -> a + + +instance Foo Bool where + o_and False x = False + o_and x False = False + o_and True True = True + + +instance Foo Int where + o_and x 0 = 0 + o_and 0 x = 0 + o_and 1 1 = 1 + + +f x y = o_and x False + +g x y = o_and x 1 + + diff --git a/ghc/tests/typecheck/should_compile/tc051.hs b/ghc/tests/typecheck/should_compile/tc051.hs new file mode 100644 index 0000000000000000000000000000000000000000..7f14282fb8d53c9dfcff5e18f7b8a5407435027d --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc051.hs @@ -0,0 +1,30 @@ +module ShouldSucceed where + +class Eq' a where + doubleeq :: a -> a -> Bool + +class (Eq' a) => Ord' a where + lt :: a -> a -> Bool + +instance Eq' Int where + doubleeq x y = True + +instance (Eq' a) => Eq' [a] where + doubleeq x y = True + +instance Ord' Int where + lt x y = True + +{- +class (Ord a) => Ix a where + range :: (a,a) -> [a] + +instance Ix Int where + range (x,y) = [x,y] +-} + + + + + + diff --git a/ghc/tests/typecheck/should_compile/tc052.hs b/ghc/tests/typecheck/should_compile/tc052.hs new file mode 100644 index 0000000000000000000000000000000000000000..108ef12046ad6db96477e422bdbf91d694216032 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc052.hs @@ -0,0 +1,8 @@ +module ShouldSucceed where + +type A a = B a + +type B c = C + +type C = Int + diff --git a/ghc/tests/typecheck/should_compile/tc053.hs b/ghc/tests/typecheck/should_compile/tc053.hs new file mode 100644 index 0000000000000000000000000000000000000000..865211d9175e86e933dce118ba004ccf4c9d13d9 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc053.hs @@ -0,0 +1,12 @@ +module ShouldSucceed where + +class Eq' a where + deq :: a -> a -> Bool + +instance Eq' Int where + deq x y = True + +instance (Eq' a) => Eq' [a] where + deq (a:as) (b:bs) = if (deq a b) then (deq as bs) else False + +f x = deq x [1] diff --git a/ghc/tests/typecheck/should_compile/tc054.hs b/ghc/tests/typecheck/should_compile/tc054.hs new file mode 100644 index 0000000000000000000000000000000000000000..df9deb08aaeafdb96be7b9582e5beb1d8fcac365 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc054.hs @@ -0,0 +1,16 @@ +module ShouldSucceed where + +class Eq' a where + doubleeq :: a -> a -> Bool + +class (Eq' a) => Ord' a where + lt :: a -> a -> Bool + +instance Eq' Int where + doubleeq x y = True + +instance Ord' Int where + lt x y = True + +f x y | lt x 1 = True + | otherwise = False diff --git a/ghc/tests/typecheck/should_compile/tc055.hs b/ghc/tests/typecheck/should_compile/tc055.hs new file mode 100644 index 0000000000000000000000000000000000000000..cdbb8f4b4d81f0a1c9b4431826bba1541a565ffb --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc055.hs @@ -0,0 +1,3 @@ +module ShouldSucceed where + +(x,y) = (\p -> p,\q -> q) diff --git a/ghc/tests/typecheck/should_compile/tc056.hs b/ghc/tests/typecheck/should_compile/tc056.hs new file mode 100644 index 0000000000000000000000000000000000000000..a9206852d4324e8bb3e6cfc05d30c5b821ce36b8 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc056.hs @@ -0,0 +1,17 @@ +--!!! Duplicate class assertion + +module ShouldSucceed where + +class Eq' a where + doubleeq :: a -> a -> Bool + +class (Eq' a) => Ord' a where + lt :: a -> a -> Bool + +instance Eq' Int where + doubleeq x y = True + +instance (Eq' a, Eq' a) => Eq' [a] where + doubleeq x y = True + +f x y = doubleeq x [1] diff --git a/ghc/tests/typecheck/should_compile/tc057.hi b/ghc/tests/typecheck/should_compile/tc057.hi new file mode 100644 index 0000000000000000000000000000000000000000..3613dfacb6086edf6c6fbbc3b573cecd04026cec --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc057.hi @@ -0,0 +1,7 @@ +interface ShouldSucceed where { +class Eq' a where { deq } +instance <Eq' Int> +instance Eq' a => <Eq' [a]> +dand :: Bool -> Bool -> Bool +f :: Eq' t93 => t93 -> t93 -> Bool +} diff --git a/ghc/tests/typecheck/should_compile/tc057.hs b/ghc/tests/typecheck/should_compile/tc057.hs new file mode 100644 index 0000000000000000000000000000000000000000..cc561b95b88e5734dc2821ce3f9185dd64e9f0eb --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc057.hs @@ -0,0 +1,18 @@ +module ShouldSucceed where + +-- See also tcfail060.hs + +class Eq' a where + deq :: a -> a -> Bool + +instance Eq' Int where + deq x y = True + +instance (Eq' a) => Eq' [a] where + deq (a:as) (b:bs) = dand (f a b) (f as bs) + +dand True True = True +dand x y = False + +f :: Eq' a => a -> a -> Bool +f p q = dand (deq p q) (deq [1::Int] [2::Int]) diff --git a/ghc/tests/typecheck/should_compile/tc058.hs b/ghc/tests/typecheck/should_compile/tc058.hs new file mode 100644 index 0000000000000000000000000000000000000000..7df1f3bc6d7f3bb7ad2d82e6446123cf9dedfb76 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc058.hs @@ -0,0 +1,18 @@ +module ShouldSucceed where + +class Eq2 a where + doubleeq :: a -> a -> Bool + +class (Eq2 a) => Ord2 a where + lt :: a -> a -> Bool + +instance Eq2 Int where + doubleeq x y = True + +instance Ord2 Int where + lt x y = True + +instance (Eq2 a,Ord2 a) => Eq2 [a] where + doubleeq xs ys = True + +f x y = doubleeq x [1] diff --git a/ghc/tests/typecheck/should_compile/tc059.hs b/ghc/tests/typecheck/should_compile/tc059.hs new file mode 100644 index 0000000000000000000000000000000000000000..f0faac8155968230cf6de449e1fc581906d87336 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc059.hs @@ -0,0 +1,15 @@ +module ShouldSucceed where + +class Eq2 a where + deq :: a -> a -> Bool + foo :: a -> a + +instance Eq2 Int where + deq x y = True + foo x = x + +instance (Eq2 a) => Eq2 [a] where + deq (a:as) (b:bs) = if (deq a (foo b)) then (deq as (foo bs)) else False + foo x = x + +f x = deq x [1] diff --git a/ghc/tests/typecheck/should_compile/tc060.hs b/ghc/tests/typecheck/should_compile/tc060.hs new file mode 100644 index 0000000000000000000000000000000000000000..6ae0ca92283677687bd0a45253f8eec04648eff4 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc060.hs @@ -0,0 +1,12 @@ +module ShouldSucceed where + +class Eq2 a where + deq :: a -> a -> Bool + +instance (Eq2 a) => Eq2 [a] where + deq (a:as) (b:bs) = if (deq a b) then (deq as bs) else False + + +instance Eq2 Int where + deq x y = True + diff --git a/ghc/tests/typecheck/should_compile/tc061.hs b/ghc/tests/typecheck/should_compile/tc061.hs new file mode 100644 index 0000000000000000000000000000000000000000..25a8b65f35573bd1a82cdb1a691bbe408a9fae66 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc061.hs @@ -0,0 +1,11 @@ +module ShouldSucceed where + +class Eq1 a where + deq :: a -> a -> Bool + +instance (Eq1 a) => Eq1 [a] where + deq (a:as) (b:bs) = deq a b + +instance Eq1 Int where + deq x y = True + diff --git a/ghc/tests/typecheck/should_compile/tc062.hs b/ghc/tests/typecheck/should_compile/tc062.hs new file mode 100644 index 0000000000000000000000000000000000000000..fde6c4b1dae5af7e595e0513ebf09515e2622619 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc062.hs @@ -0,0 +1,12 @@ +module ShouldSucceed where + +class Eq1 a where + deq :: a -> a -> Bool + +instance Eq1 Int where + deq x y = True + +instance (Eq1 a) => Eq1 [a] where + deq (a:as) (b:bs) = if (deq a b) then (deq as bs) else False + +f x (y:ys) = deq x ys diff --git a/ghc/tests/typecheck/should_compile/tc063.hs b/ghc/tests/typecheck/should_compile/tc063.hs new file mode 100644 index 0000000000000000000000000000000000000000..36affbfdcedbc2a306b67a64c3d3749d12169768 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc063.hs @@ -0,0 +1,18 @@ +module ShouldSucceed where + +data X a = Tag a + +class Reps r where + f :: r -> r -> r + +instance Reps (X q) where +-- f (Tag x) (Tag y) = Tag y + f x y = y + +instance Reps Bool where + f True True = True + f x y = False + +g x = f x x + + diff --git a/ghc/tests/typecheck/should_compile/tc064.hs b/ghc/tests/typecheck/should_compile/tc064.hs new file mode 100644 index 0000000000000000000000000000000000000000..18aecb091d34d70bb005fbce97da9975e34a0a18 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc064.hs @@ -0,0 +1,7 @@ +module ShouldSucceed where + +data Boolean = FF | TT + +idb :: Boolean -> Boolean +idb x = x + diff --git a/ghc/tests/typecheck/should_compile/tc065.hs b/ghc/tests/typecheck/should_compile/tc065.hs new file mode 100644 index 0000000000000000000000000000000000000000..14de5930512f7da097750b40acc0e5f39951dc77 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc065.hs @@ -0,0 +1,107 @@ +module Digraphs where + +import TheUtils +import Set +import List (partition ) + +data Digraph vertex = MkDigraph [vertex] + +type Edge vertex = (vertex, vertex) +type Cycle vertex = [vertex] + +mkDigraph = MkDigraph + +stronglyConnComp :: Eq vertex => [Edge vertex] -> [vertex] -> [[vertex]] +stronglyConnComp es vs + = snd (span_tree (new_range reversed_edges) + ([],[]) + ( snd (dfs (new_range es) ([],[]) vs) ) + ) + where + reversed_edges = map swap es + + swap :: Edge v -> Edge v + swap (x,y) = (y, x) + + new_range [] w = [] + new_range ((x,y):xys) w + = if x==w + then (y : (new_range xys w)) + else (new_range xys w) + + span_tree r (vs,ns) [] = (vs,ns) + span_tree r (vs,ns) (x:xs) + | x `elem` vs = span_tree r (vs,ns) xs + | otherwise = span_tree r (vs',(x:ns'):ns) xs + where + (vs',ns') = dfs r (x:vs,[]) (r x) + +dfs r (vs,ns) [] = (vs,ns) +dfs r (vs,ns) (x:xs) | x `elem` vs = dfs r (vs,ns) xs + | otherwise = dfs r (vs',(x:ns')++ns) xs + where + (vs',ns') = dfs r (x:vs,[]) (r x) + + +isCyclic :: Eq vertex => [Edge vertex] -> [vertex] -> Bool +isCyclic edges [v] = (v,v) `elem` edges +isCyclic edges vs = True + + +topSort :: (Eq vertex) => [Edge vertex] -> [vertex] + -> MaybeErr [vertex] [[vertex]] + + +topSort edges vertices + = case cycles of + [] -> Succeeded [v | [v] <- singletons] + _ -> Failed cycles + where + sccs = stronglyConnComp edges vertices + (cycles, singletons) = partition (isCyclic edges) sccs + + +type FlattenedDependencyInfo vertex name code + = [(vertex, Set name, Set name, code)] + +mkVertices :: FlattenedDependencyInfo vertex name code -> [vertex] +mkVertices info = [ vertex | (vertex,_,_,_) <- info] + +mkEdges :: (Eq vertex, Ord name) => + [vertex] + -> FlattenedDependencyInfo vertex name code + -> [Edge vertex] + +mkEdges vertices flat_info + = [ (source_vertex, target_vertex) + | (source_vertex, _, used_names, _) <- flat_info, + target_name <- setToList used_names, + target_vertex <- vertices_defining target_name flat_info + ] + where + vertices_defining name flat_info + = [ vertex | (vertex, names_defined, _, _) <- flat_info, + name `elementOf` names_defined + ] + +lookupVertex :: (Eq vertex, Ord name) => + FlattenedDependencyInfo vertex name code + -> vertex + -> code + +lookupVertex flat_info vertex + = head code_list + where + code_list = [ code | (vertex',_,_,code) <- flat_info, vertex == vertex'] + + +isRecursiveCycle :: (Eq vertex) => Cycle vertex -> [Edge vertex] -> Bool +isRecursiveCycle [vertex] edges = (vertex, vertex) `elem` edges +isRecursiveCycle cycle edges = True + + + +-- may go to TheUtils + +data MaybeErr a b = Succeeded a | Failed b + diff --git a/ghc/tests/typecheck/should_compile/tc066.hs b/ghc/tests/typecheck/should_compile/tc066.hs new file mode 100644 index 0000000000000000000000000000000000000000..7c929516bc0011aeee15892211652035969c285e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc066.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +data Pair a b = MkPair a b +f x = [ a | (MkPair c a) <- x ] diff --git a/ghc/tests/typecheck/should_compile/tc067.hs b/ghc/tests/typecheck/should_compile/tc067.hs new file mode 100644 index 0000000000000000000000000000000000000000..59df10316cdcde55743013e7216ef9630ce30c09 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc067.hs @@ -0,0 +1,4 @@ +module ShouldSucc where + +f [] = [] +f (x:xs) = x : (f xs) diff --git a/ghc/tests/typecheck/should_compile/tc068.hs b/ghc/tests/typecheck/should_compile/tc068.hs new file mode 100644 index 0000000000000000000000000000000000000000..01f2d872e6ccd2a092d4a96af82d857d72da8b02 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc068.hs @@ -0,0 +1,18 @@ +module ShouldSucc where + +data T a = D (B a) | C +data B b = X | Y b + +instance (Eq a) => Eq (T a) where + (D x) == (D y) = x == y + C == C = True + a == b = False + + a /= b = not (a == b) + +instance (Eq b) => Eq (B b) where + X == X = True + (Y a) == (Y b) = a == b + a == b = False + + a /= b = not (a == b) diff --git a/ghc/tests/typecheck/should_compile/tc069.hs b/ghc/tests/typecheck/should_compile/tc069.hs new file mode 100644 index 0000000000000000000000000000000000000000..539b3046da70e5a483ca1cc7a0bc157ef7edd81d --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc069.hs @@ -0,0 +1,4 @@ +module ShouldSucceed where + +x = 'a' +(y:ys) = ['a','b','c'] where p = x diff --git a/ghc/tests/typecheck/should_compile/tc070.hs b/ghc/tests/typecheck/should_compile/tc070.hs new file mode 100644 index 0000000000000000000000000000000000000000..831195f9f6269fb3634cab100d0880d1fa68cf20 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc070.hs @@ -0,0 +1,9 @@ +module ShouldSucceed where + + +data Boolean = FF | TT + + +idb :: Boolean -> Boolean +idb x = x + diff --git a/ghc/tests/typecheck/should_compile/tc073.hs b/ghc/tests/typecheck/should_compile/tc073.hs new file mode 100644 index 0000000000000000000000000000000000000000..ea4cb74675cd37584df9192188e4dd1be8439f2a --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc073.hs @@ -0,0 +1,5 @@ + +module ShouldSucc where + +f [] = [] +f (x:xs) = x : (f xs) diff --git a/ghc/tests/typecheck/should_compile/tc074.hs b/ghc/tests/typecheck/should_compile/tc074.hs new file mode 100644 index 0000000000000000000000000000000000000000..01f2d872e6ccd2a092d4a96af82d857d72da8b02 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc074.hs @@ -0,0 +1,18 @@ +module ShouldSucc where + +data T a = D (B a) | C +data B b = X | Y b + +instance (Eq a) => Eq (T a) where + (D x) == (D y) = x == y + C == C = True + a == b = False + + a /= b = not (a == b) + +instance (Eq b) => Eq (B b) where + X == X = True + (Y a) == (Y b) = a == b + a == b = False + + a /= b = not (a == b) diff --git a/ghc/tests/typecheck/should_compile/tc076.hs b/ghc/tests/typecheck/should_compile/tc076.hs new file mode 100644 index 0000000000000000000000000000000000000000..5bf422e5c937444afe0c6ffa7157359b1f938e26 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc076.hs @@ -0,0 +1,8 @@ +--!!! scoping in list comprehensions right way 'round? +-- a bug reported by Jon Hill +-- +module ShouldSucceed where + +x = [[True]] +xs :: [Bool] +xs = [x | x <- x, x <- x] diff --git a/ghc/tests/typecheck/should_compile/tc077.hs b/ghc/tests/typecheck/should_compile/tc077.hs new file mode 100644 index 0000000000000000000000000000000000000000..c9bb8d53a8864d5f4e75d1eec08fc999d3110f8d --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc077.hs @@ -0,0 +1,9 @@ +--!!! make sure context of EQ is minimised in interface file. +-- +module M where + +data NUM = ONE | TWO +class (Num a) => ORD a + +class (ORD a, Show a) => EQ a where + (===) :: a -> a -> Bool diff --git a/ghc/tests/typecheck/should_compile/tc078.hs b/ghc/tests/typecheck/should_compile/tc078.hs new file mode 100644 index 0000000000000000000000000000000000000000..a35afef81e050964d10eeeaec05e7a8f67cdf50a --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc078.hs @@ -0,0 +1,8 @@ +--!!! instance decls with no binds +-- +module M where + +data Bar a = MkBar Int a + +instance Eq a => Eq (Bar a) +instance Ord a => Ord (Bar a) diff --git a/ghc/tests/typecheck/should_compile/tc079.hs b/ghc/tests/typecheck/should_compile/tc079.hs new file mode 100644 index 0000000000000000000000000000000000000000..d49f4ce43a6bca853b49e36775cecf28173af78a --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc079.hs @@ -0,0 +1,16 @@ +--!!! small class decl with local polymorphism; +--!!! "easy" to check default methods and such... +--!!! (this is the example given in TcClassDcl) +-- +module Test where + +class Foo a where + op1 :: a -> Bool + op2 :: Ord b => a -> b -> b -> b + + op1 x = True + op2 x y z = if (op1 x) && (y < z) then y else z + +instance Foo Int where {} + +instance Foo a => Foo [a] where {} diff --git a/ghc/tests/typecheck/should_compile/tc080.hs b/ghc/tests/typecheck/should_compile/tc080.hs new file mode 100644 index 0000000000000000000000000000000000000000..d9ad6e9902f4918d1d583f1bbe099b8bed4a8013 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc080.hs @@ -0,0 +1,53 @@ +--module Parse(Parse(..),whiteSpace,seperatedBy) where +--import StdLib +class Parse a where + parseFile :: String -> [a] + parseFile string | all forced x = x + where x = map parseLine (lines' string) + parseLine :: String -> a + parseLine = pl.parse where pl (a,_) = a + parse :: String -> (a,String) + parse = parseType.whiteSpace + parseType :: String -> (a,String) + forced :: a -> Bool + forced x = True + +instance Parse Int where + parseType str = pl (span' isDigit str) + where pl (l,r) = (strToInt l,r) + forced n | n>=0 = True + +instance Parse Char where + parseType (ch:str) = (ch,str) + forced n = True + +instance (Parse a) => Parse [a] where + parseType more = (map parseLine (seperatedBy ',' (l++",")),out) + where (l,']':out) = span' (\x->x/=']') (tail more) + forced = all forced + +seperatedBy :: Char -> String -> [String] +seperatedBy ch [] = [] +seperatedBy ch xs = twaddle ch (span' (\x->x/=ch) xs) + where twaddle ch (l,_:r) = l:seperatedBy ch r + +whiteSpace :: String -> String +whiteSpace = dropWhile isSpace + +span' :: (a->Bool) -> [a] -> ([a],[a]) +span' p [] = ([],[]) +span' p (x:xs') | p x = fixLeak x (span' p xs') where fixLeak x (xs,ys) = (x:xs,ys) +span' _ xs = ([],xs) + +lines' :: [Char] -> [[Char]] +lines' "" = [] +lines' s = plumb (span' ((/=) '\n') s) + where plumb (l,s') = l:if null s' then [] else lines' (tail s') + +strToInt :: String -> Int +strToInt x = strToInt' (length x-1) x + where strToInt' _ [] = 0 + strToInt' x (a:l) = (charToInt a)*(10^x) + (strToInt' (x-1) l) + +charToInt :: Char -> Int +charToInt x = (ord x - ord '0') diff --git a/ghc/tests/typecheck/should_compile/tc081.hs b/ghc/tests/typecheck/should_compile/tc081.hs new file mode 100644 index 0000000000000000000000000000000000000000..6590550cf670ae95778a5c35457645eb7473e89e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc081.hs @@ -0,0 +1,28 @@ +--!!! an example Simon made up +-- +module ShouldSucceed where + +f x = (x+1, x<3, g True, g 'c') + where + g y = if x>2 then [] else [y] +{- +Here the type-check of g will yield an LIE with an Ord dict +for x. g still has type forall a. a -> [a]. The dictionary is +free, bound by the x. + +It should be ok to add the signature: +-} + +f2 x = (x+1, x<3, g2 True, g2 'c') + where + -- NB: this sig: + g2 :: a -> [a] + g2 y = if x>2 then [] else [y] +{- +or to write: +-} + +f3 x = (x+1, x<3, g3 True, g3 'c') + where + -- NB: this line: + g3 = (\ y -> if x>2 then [] else [y])::(a -> [a]) diff --git a/ghc/tests/typecheck/should_compile/tc082.hs b/ghc/tests/typecheck/should_compile/tc082.hs new file mode 100644 index 0000000000000000000000000000000000000000..f2ccb367361b60b9d0630f03de041273637bdd37 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc082.hs @@ -0,0 +1,12 @@ +--!!! tc082: an instance for functions +-- +module N where + +class Normal a + where + normal :: a -> Bool + +instance Normal ( a -> b ) where + normal _ = True + +f x = normal id diff --git a/ghc/tests/typecheck/should_compile/tc083.hs b/ghc/tests/typecheck/should_compile/tc083.hs new file mode 100644 index 0000000000000000000000000000000000000000..1c5321e63115783956422bb3f130edac86d482f5 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc083.hs @@ -0,0 +1,10 @@ +--!!! instances with no binds; +--!!! be sure we get a legit .hi file +-- +module Bar where + +import ClassFoo + +instance Foo Int + +instance Foo a => Foo [a] diff --git a/ghc/tests/typecheck/should_compile/tc084.hs b/ghc/tests/typecheck/should_compile/tc084.hs new file mode 100644 index 0000000000000000000000000000000000000000..572bbe31dc97f6153169f869be6d9f056d3830e5 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc084.hs @@ -0,0 +1,23 @@ +{- This program shows up a bug in the handling of + the monomorphism restriction in an earlier version of + ghc. With ghc 0.18 and before, f gets a type with + an unbound type variable, which shows up in the + interface file. Reason: it was being monomorphised. + + Simon PJ +-} + +module Foo where + + +g :: Num a => Bool -> a -> b -> a +g b x y = if b then x+x else x-x + +-- Everything is ok if this signature is put in +-- but the program should be perfectly legal without it. +-- f :: Num a => a -> b -> a +f = g True + +h y x = f (x::Int) y + -- This use of f binds the overloaded monomorphic + -- type to Int diff --git a/ghc/tests/typecheck/should_compile/tc085.hs b/ghc/tests/typecheck/should_compile/tc085.hs new file mode 100644 index 0000000000000000000000000000000000000000..fe5ad6a8ae7fa68d0d68cd116f33bb418dc2de57 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc085.hs @@ -0,0 +1,9 @@ +--!!! From a bug report from Satnam. +--!!! To do with re-exporting importees from PreludeGla* modules. +module Foo ( module GlaExts, module Foo ) where + +--OLD: import PreludeGlaIO +import GlaExts + +type FooType = Int +data FooData = FooData diff --git a/ghc/tests/typecheck/should_compile/tc086.hs b/ghc/tests/typecheck/should_compile/tc086.hs new file mode 100644 index 0000000000000000000000000000000000000000..4d9ba6edb6461442c5572c6229841f134e87ee2e --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc086.hs @@ -0,0 +1,60 @@ +{- + From: Marc van Dongen <dongen@cs.ucc.ie> + Date: Sat, 31 May 1997 19:57:46 +0100 (BST) + + panic! (the `impossible' happened): + tcLookupTyVar:a_r6F + + Please report it as a compiler bug to glasgow-haskell-bugs@dcs.gla.ac.uk. + + +If the instance definition for (*) at the end of this toy module +is replaced by the definition that is commented, this all compiles +fine. Strange, because the two implementations are equivalent modulo +the theory {(*) = multiply}. + +Remove the `multiply :: a -> a -> a' part, and it compiles without +problems. + + +SPJ note: the type signature on "multiply" should be + multiply :: Group a => a -> a -> a + +-} + +module Rings( Group, Ring ) where + +import qualified Prelude( Ord(..), Eq(..), Num(..) ) +import Prelude hiding( Ord(..), Eq(..), Num(..), MonadZero( zero ) ) + +class Group a where + compare :: a -> a -> Prelude.Ordering + fromInteger :: Integer -> a + (+) :: a -> a -> a + (-) :: a -> a -> a + zero :: a + one :: a + zero = fromInteger 0 + one = fromInteger 1 + +-- class (Group a) => Ring a where +-- (*) :: a -> a -> a +-- (*) a b = +-- case (compare a zero) of +-- EQ -> zero +-- LT -> zero - ((*) (zero - a) b) +-- GT -> case compare a one of +-- EQ -> b +-- _ -> b + ((*) (a - one) b) + +class (Group a) => Ring a where + (*) :: a -> a -> a + (*) a b = multiply a b + where multiply :: Group a => a -> a ->a + multiply a b + = case (compare a zero) of + EQ -> zero + LT -> zero - (multiply (zero - a) b) + GT -> case compare a one of + EQ -> b + _ -> b + (multiply (a - one) b) diff --git a/ghc/tests/typecheck/should_compile/tc087.hs b/ghc/tests/typecheck/should_compile/tc087.hs new file mode 100644 index 0000000000000000000000000000000000000000..8477427e1176b7fe125736ec595f6f0c10133c1d --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc087.hs @@ -0,0 +1,32 @@ +module SOL where + +import GlaExts + +data SeqView t a = Null + | Cons a (t a) + +class PriorityQueue q where + empty :: (Ord a) => q a + single :: (Ord a) => a -> q a + insert :: (Ord a) => a -> q a -> q a + meld :: (Ord a) => q a -> q a -> q a + splitMin :: (Ord a) => q a -> SeqView q a + insert a q = single a `meld` q + +toOrderedList q = case splitMin q of + Null -> [] + Cons a q -> a : toOrderedList q + +insertMany x q = foldr insert q x +pqSort q x = toOrderedList (insertMany x q) + +check :: (PriorityQueue q) => (Ord a => q a) -> IO () +check empty = do + putStr "*** sorting\n" + out (pqSort empty [1 .. 99]) + out (pqSort empty [1.0, 1.1 ..99.9]) + +out :: (Num a) => [a] -> IO () +out x | sum x == 0 = putStr "ok\n" + | otherwise = putStr "ok\n" + diff --git a/ghc/tests/typecheck/should_compile/tc088.hs b/ghc/tests/typecheck/should_compile/tc088.hs new file mode 100644 index 0000000000000000000000000000000000000000..e1b8b88dd6eb07b0dfc43e2a55f131d6fe7570d2 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc088.hs @@ -0,0 +1,18 @@ +-- Check that "->" is an instance of Eval + +module Foo where + +instance (Eq b) => Eq (a -> b) where + (==) f g = error "attempt to compare functions" + + -- Since Eval is a superclass of Num this fails + -- unless -> is an instance of Eval +instance (Num b) => Num (a -> b) where + f + g = \a -> f a + g a + f - g = \a -> f a - g a + f * g = \a -> f a * g a + negate f = \a -> negate (f a) + abs f = \a -> abs (f a) + signum f = \a -> signum (f a) + fromInteger n = \a -> fromInteger n + fromInt n = \a -> fromInt n diff --git a/ghc/tests/typecheck/should_compile/tc089.hs b/ghc/tests/typecheck/should_compile/tc089.hs new file mode 100644 index 0000000000000000000000000000000000000000..1143906507f0dbe598f25e2edc730888c4ba314a --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc089.hs @@ -0,0 +1,78 @@ +--!!! Stress test for type checker + +module Prims where + +import Prelude hiding (head) + +one = one + +head (x:xs) = x + +bottom = head + +absIf a b c = a + +absAnd a b = head [a,b] + +fac_rec fac0 n a + = (absIf (absAnd (s_3_0 n) one) + (s_2_0 a) + (fac0 (absAnd (s_3_2 n) one) (absAnd (s_3_1 n) (s_2_1 a)))) + +f_rec f0 a + = (f0 (s_1_0 a)) + +g_rec g0 g1 x y z p + = (absIf (absAnd (s_3_0 p) one) + (absAnd (s_1_0 x) (s_3_0 z)) + (absAnd + (g0 (s_1_0 y) one one (absAnd (s_3_1 p) one)) + (g1 (s_3_2 z) (s_3_1 z) one (absAnd (s_3_2 p) one)))) + +s_2_0 (v0,v1) = v0 +s_2_1 (v0,v1) = v1 +s_1_0 v0 = v0 +s_3_0 (v0,v1,v2) = v0 +s_3_1 (v0,v1,v2) = v1 +s_3_2 (v0,v1,v2) = v2 + +fac n a + = (fac_rec fac_rec4 n a) + +fac_rec4 n a = (fac_rec fac_rec3 n a) +fac_rec3 n a = (fac_rec fac_rec2 n a) +fac_rec2 n a = (fac_rec fac_rec1 n a) +fac_rec1 n a = (fac_rec fac_rec0 n a) +fac_rec0 n a = (bottom [n,a]) + +f a + = (f_rec f_rec2 a) + +f_rec2 a = (f_rec f_rec1 a) +f_rec1 a = (f_rec f_rec0 a) +f_rec0 a = (bottom [a]) + +g x y z p = (g_rec g_rec8 g_rec8 x y z p) + +{- +g x y z p = (g_rec g_rec16 g_rec16 x y z p) + +g_rec16 x y z p = (g_rec g_rec15 g_rec15 x y z p) +g_rec15 x y z p = (g_rec g_rec14 g_rec14 x y z p) +g_rec14 x y z p = (g_rec g_rec13 g_rec13 x y z p) +g_rec13 x y z p = (g_rec g_rec12 g_rec12 x y z p) +g_rec12 x y z p = (g_rec g_rec11 g_rec11 x y z p) +g_rec11 x y z p = (g_rec g_rec10 g_rec10 x y z p) +g_rec10 x y z p = (g_rec g_rec9 g_rec9 x y z p) +g_rec9 x y z p = (g_rec g_rec8 g_rec8 x y z p) +-} + +g_rec8 x y z p = (g_rec g_rec7 g_rec7 x y z p) +g_rec7 x y z p = (g_rec g_rec6 g_rec6 x y z p) +g_rec6 x y z p = (g_rec g_rec5 g_rec5 x y z p) +g_rec5 x y z p = (g_rec g_rec4 g_rec4 x y z p) +g_rec4 x y z p = (g_rec g_rec3 g_rec3 x y z p) +g_rec3 x y z p = (g_rec g_rec2 g_rec2 x y z p) +g_rec2 x y z p = (g_rec g_rec1 g_rec1 x y z p) +g_rec1 x y z p = (g_rec g_rec0 g_rec0 x y z p) +g_rec0 x y z p = (bottom [x,y,z,p]) diff --git a/ghc/tests/typecheck/should_compile/tc090.hs b/ghc/tests/typecheck/should_compile/tc090.hs new file mode 100644 index 0000000000000000000000000000000000000000..bbcc17428e9c167a8980786908049f90f2857aec --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc090.hs @@ -0,0 +1,22 @@ +{- This module tests that we can ge polymorphic recursion + of overloaded functions. GHC 2.02 produced the following + bogus error: + + tmp.lhs:1: A group of type signatures have mismatched contexts + Abf.a :: (PrelBase.Ord f{-aX6-}) => ... + Abf.b :: (PrelBase.Ord f{-aX2-}) => ... + + This was due to having more than one type signature for one + group of recursive functions. +-} + + +module Foo where + +a :: (Ord f) => f +a = b + +b :: (Ord f) => f +b = a + + diff --git a/ghc/tests/typecheck/should_compile/tc091.hs b/ghc/tests/typecheck/should_compile/tc091.hs new file mode 100644 index 0000000000000000000000000000000000000000..fc4e82cf756319dc86ab5aaf7143cb7d3eaf8920 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc091.hs @@ -0,0 +1,67 @@ +--!!! Test polymorphic recursion + + +-- With polymorphic recursion this one becomes legal +-- SLPJ June 97. + +{- +To: Lennart Augustsson <augustss@cs.chalmers.se> +Cc: partain@dcs.gla.ac.uk, John Peterson (Yale) <peterson-john@cs.yale.edu>, + simonpj@dcs.gla.ac.uk +Subject: Type checking matter +Date: Fri, 23 Oct 92 15:28:38 +0100 +From: Simon L Peyton Jones <simonpj@dcs.gla.ac.uk> + + +I've looked at the enclosed again. It seems to me that +since "s" includes a recursive call to "sort", inside the body +of "sort", then "sort" is monomorphic, and hence so is "s"; +hence the type signature (which claims full polymorphism) is +wrong. + +[Lennart says he can't see any free variables inside "s", but there +is one, namely "sort"!] + +Will: one for the should-fail suite? + +Simon + + +------- Forwarded Message + + +From: Lennart Augustsson <augustss@cs.chalmers.se> +To: partain +Subject: Re: just to show you I'm a nice guy... +Date: Tue, 26 May 92 17:30:12 +0200 + +> Here's a fairly simple module from our compiler, which includes what +> we claim is an illegal type signature (grep ILLEGAL ...). +> Last time I checked, hbc accepted this module. + +Not that I don't believe you, but why is this illegal? +As far as I can see there are no free variables in the function s, +which makes me believe that it can typechecked like a top level +definition. And for a top level defn the signature should be +all right. + + -- Lennart +- ------- End of forwarded message ------- +-} +module ShouldFail where + +sort :: Ord a => [a] -> [a] +sort xs = s xs (length xs) + where + s :: Ord b => [b] -> Int -> [b] -- This signature is WRONG + s xs k = if k <= 1 then xs + else merge (sort ys) (sort zs) + where (ys,zs) = init_last xs (k `div` (2::Int)) + +-- Defns of merge and init_last are just dummies with the correct types +merge :: Ord a => [a] -> [a] -> [a] +merge xs ys = xs + +init_last :: [a] -> Int -> ([a],[a]) +init_last a b = (a,a) + diff --git a/ghc/tests/typecheck/should_fail/Digraph.hs b/ghc/tests/typecheck/should_fail/Digraph.hs new file mode 100644 index 0000000000000000000000000000000000000000..a52d489b2c0b3aac79ed1e7652de93c3e9b3e03c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/Digraph.hs @@ -0,0 +1,56 @@ +--!!! trying to have a polymorphic type sig where inappropriate +-- +module Digraph where + +data MaybeErr val err = Succeeded val | Failed err deriving () + +type Edge vertex = (vertex, vertex) +type Cycle vertex = [vertex] + +stronglyConnComp :: Eq vertex => [Edge vertex] -> [vertex] -> [[vertex]] + +stronglyConnComp es vs + = snd (span_tree (new_range reversed_edges) + ([],[]) + ( snd (dfs (new_range es) ([],[]) vs) ) + ) + where + -- *********** the offending type signature ************** + reversed_edges :: Eq v => [Edge v] + reversed_edges = map swap es + + -- WRONGOLA: swap :: Eq v => Edge v -> Edge v + swap (x,y) = (y, x) + + -- WRONGOLA?: new_range :: Eq v => [Edge v] -> v -> [v] + + new_range [] w = [] + new_range ((x,y):xys) w + = if x==w + then (y : (new_range xys w)) + else (new_range xys w) + + {- WRONGOLA?: + span_tree :: Eq v => (v -> [v]) + -> ([v], [[v]]) + -> [v] + -> ([v], [[v]]) + -} + + span_tree r (vs,ns) [] = (vs,ns) + span_tree r (vs,ns) (x:xs) + | x `elem` vs = span_tree r (vs,ns) xs + | otherwise = span_tree r (vs',(x:ns'):ns) xs + where + (vs',ns') = dfs r (x:vs,[]) (r x) + +dfs :: Eq v => (v -> [v]) + -> ([v], [v]) + -> [v] + -> ([v], [v]) + +dfs r (vs,ns) [] = (vs,ns) +dfs r (vs,ns) (x:xs) | x `elem` vs = dfs r (vs,ns) xs + | otherwise = dfs r (vs',(x:ns')++ns) xs + where + (vs',ns') = dfs r (x:vs,[]) (r x) diff --git a/ghc/tests/typecheck/should_fail/Digraph.stderr b/ghc/tests/typecheck/should_fail/Digraph.stderr new file mode 100644 index 0000000000000000000000000000000000000000..6efcc42e3986b71d96d3670dbc61ccd475a06749 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/Digraph.stderr @@ -0,0 +1,34 @@ + +Digraph.hs:19: A type signature is more polymorphic than the inferred type + Some type variables in the inferred type can't be forall'd, namely: + `taXO' + Possible cause: the RHS mentions something subject to the monomorphism restriction + When checking signature for `reversed_edges' + In an equation for function `stronglyConnComp': + `stronglyConnComp es vs + = PrelTup.snd (span_tree (new_range reversed_edges) + (PrelBase.[], (PrelBase.[])) + (PrelTup.snd (dfs (new_range es) + (PrelBase.[], (PrelBase.[])) + vs))) + where + span_tree r (vs, ns) PrelBase.[] = (vs, (ns)) + span_tree r (vs, ns) (x PrelBase.: xs) + | [x PrelList.elem vs] = span_tree r (vs, (ns)) xs + | [PrelBase.otherwise] + = span_tree r (vs', ((x PrelBase.: ns') PrelBase.: ns)) xs + where + (vs', ns') + = dfs r (x PrelBase.: vs, (PrelBase.[])) (r x) + new_range PrelBase.[] w = PrelBase.[] + new_range ((x, y) PrelBase.: xys) w + = if x PrelBase.== w then + (y PrelBase.: (new_range xys w)) + else + (new_range xys w) + swap (x, y) = (y, (x)) + reversed_edges :: _forall_ [v] (PrelBase.Eq v) => [Edge v] + reversed_edges = PrelBase.map swap es' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/Makefile b/ghc/tests/typecheck/should_fail/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..eb7ffddce92046c40ec711ab9709459f2ba4c2df --- /dev/null +++ b/ghc/tests/typecheck/should_fail/Makefile @@ -0,0 +1,26 @@ +TOP = ../../../.. +include $(TOP)/mk/boilerplate.mk + +HS_SRCS = $(wildcard *.hs) + +SRC_RUNTEST_OPTS += -o1 $*.stdout -o2 $*.stderr -x 1 +HC_OPTS += -noC -ddump-tc + +%.o : %.hs + $(RUNTEST) $(HC) $(RUNTEST_OPTS) -- $(HC_OPTS) -c $< -o $@ + +all :: $(HS_OBJS) + +tcfail045_HC_OPTS = -fglasgow-exts +tcfail059_HC_OPTS = -hi +tcfail060_HC_OPTS = -hi +tcfail061_HC_OPTS = -hi +tcfail062_HC_OPTS = -hi +tcfail063_HC_OPTS = -hi +tcfail064_HC_OPTS = -hi +tcfail065_HC_OPTS = -hi +tcfail066_HC_OPTS = -hi +tcfail067_HC_OPTS = -hi +tcfail068_HC_OPTS = -fglasgow-exts + +include $(TOP)/mk/target.mk diff --git a/ghc/tests/typecheck/should_fail/tcfail001.hs b/ghc/tests/typecheck/should_fail/tcfail001.hs new file mode 100644 index 0000000000000000000000000000000000000000..dafb83af1e76576970af2d51401a074644c59964 --- /dev/null +++ b/ghc/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 Test where + +class A a where + op :: a + +instance (A a, A a) => A [a] where + op [] = [] diff --git a/ghc/tests/typecheck/should_fail/tcfail001.stderr b/ghc/tests/typecheck/should_fail/tcfail001.stderr new file mode 100644 index 0000000000000000000000000000000000000000..1b5ad86cafc077ba48f805543b1e6157c514313d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail001.stderr @@ -0,0 +1,12 @@ + +tcfail001.hs:9:warning: + Duplicated class assertion `A a' in context: `(A a, A a)' + +tcfail001.hs:9: Couldn't match the type + `PrelBase.[]' against `GHC.-> [takw]' + Expected: `[takv]' + Inferred: `[takw] -> [takx]' + In an equation for function `op': `op PrelBase.[] = PrelBase.[]' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail002.hs b/ghc/tests/typecheck/should_fail/tcfail002.hs new file mode 100644 index 0000000000000000000000000000000000000000..b1fdd165b432034d39080247b7f991689f7a5ee3 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail002.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +c (x:y) = x +c z = z diff --git a/ghc/tests/typecheck/should_fail/tcfail002.stderr b/ghc/tests/typecheck/should_fail/tcfail002.stderr new file mode 100644 index 0000000000000000000000000000000000000000..390e47948e4f5ff5ae6f4670707e1183b46e6418 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail002.stderr @@ -0,0 +1,9 @@ + +tcfail002.hs:4: Cannot construct the infinite type (occur check) + `tak5' = `[tak5]' + Expected: `[tak5] -> tak5' + Inferred: `[tak5] -> [tak5]' + In an equation for function `c': `c z = z' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail003.hs b/ghc/tests/typecheck/should_fail/tcfail003.hs new file mode 100644 index 0000000000000000000000000000000000000000..8458014c1bfffc1c7216bdcdf7633f226b3ac6de --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail003.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(d:e) = [1,'a'] diff --git a/ghc/tests/typecheck/should_fail/tcfail003.stderr b/ghc/tests/typecheck/should_fail/tcfail003.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8b9128c7c693895005bc0874a1227256294094de --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail003.stderr @@ -0,0 +1,6 @@ + +tcfail003.hs:3: No instance for: `PrelBase.Num PrelBase.Char' + arising from the literal 1 at tcfail003.hs:3 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail004.hs b/ghc/tests/typecheck/should_fail/tcfail004.hs new file mode 100644 index 0000000000000000000000000000000000000000..513680bd12263915c6e71b6c5a99e9cb3fd08e40 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail004.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(f,g) = (1,2,3) diff --git a/ghc/tests/typecheck/should_fail/tcfail004.stderr b/ghc/tests/typecheck/should_fail/tcfail004.stderr new file mode 100644 index 0000000000000000000000000000000000000000..a4f4e317c333bb8aab20825df9a57d1a93633587 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail004.stderr @@ -0,0 +1,9 @@ + +tcfail004.hs:3: Couldn't match the type + `PrelTup.(,)' against `PrelTup.(,,) taRU' + Expected: `(taRO, taRR)' + Inferred: `(taRU, taRX, taS0)' + In a pattern binding: `(f, g) = (1, 2, 3)' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail005.hs b/ghc/tests/typecheck/should_fail/tcfail005.hs new file mode 100644 index 0000000000000000000000000000000000000000..ca211e12165b7b388439710f57d4258703db4f49 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail005.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +(h:i) = (1,'a') diff --git a/ghc/tests/typecheck/should_fail/tcfail005.stderr b/ghc/tests/typecheck/should_fail/tcfail005.stderr new file mode 100644 index 0000000000000000000000000000000000000000..9d0fbc3b02857e1ea6109dd7542bcf6a815ede1b --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail005.stderr @@ -0,0 +1,9 @@ + +tcfail005.hs:3: Couldn't match the type + `PrelBase.[]' against `PrelTup.(,) taR8' + Expected: `[taR4]' + Inferred: `(taR8, PrelBase.Char)' + In a pattern binding: `(h PrelBase.: i) = (1, ('a'))' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail006.hs b/ghc/tests/typecheck/should_fail/tcfail006.hs new file mode 100644 index 0000000000000000000000000000000000000000..37fd1f9c358ffe3bfdb312e3de971275c384aa64 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail006.stderr b/ghc/tests/typecheck/should_fail/tcfail006.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8ec9ddad86ba9f1ca141e2b4e3c2e50807e41c5b --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail006.stderr @@ -0,0 +1,6 @@ + +tcfail006.hs:4: No instance for: `PrelBase.Num PrelBase.Bool' + arising from the literal 1 at tcfail006.hs:4 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail007.hs b/ghc/tests/typecheck/should_fail/tcfail007.hs new file mode 100644 index 0000000000000000000000000000000000000000..ee24983aff055d3cbf490134545d5893a42ea489 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail007.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +n x | True = x+1 + | False = True diff --git a/ghc/tests/typecheck/should_fail/tcfail007.stderr b/ghc/tests/typecheck/should_fail/tcfail007.stderr new file mode 100644 index 0000000000000000000000000000000000000000..070501c09f33ad08f9734a0c09d7557cb56e394f --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail007.stderr @@ -0,0 +1,6 @@ + +tcfail007.hs:4: No instance for: `PrelBase.Num PrelBase.Bool' + arising from use of `PrelBase.+' at tcfail007.hs:4 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail008.hs b/ghc/tests/typecheck/should_fail/tcfail008.hs new file mode 100644 index 0000000000000000000000000000000000000000..dbc9d0c911f2eced74d5657601817361088c216d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail008.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +o = 1:2 diff --git a/ghc/tests/typecheck/should_fail/tcfail008.stderr b/ghc/tests/typecheck/should_fail/tcfail008.stderr new file mode 100644 index 0000000000000000000000000000000000000000..2ee93213d2ce026db38cdcd3e76b33c635cf9d20 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail008.stderr @@ -0,0 +1,12 @@ + +tcfail008.hs:3: No instance for: `PrelBase.Num [taBA]' + arising from the literal 2 at tcfail008.hs:3 + +tcfail008.hs:3: No instance for: `PrelBase.Num [taBA]' + arising from the literal 2 at tcfail008.hs:3 + +tcfail008.hs:3: No instance for: `PrelBase.Num [PrelBase.Int]' + arising from the literal 2 at tcfail008.hs:3 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail009.hs b/ghc/tests/typecheck/should_fail/tcfail009.hs new file mode 100644 index 0000000000000000000000000000000000000000..e8afa0fbf7ef80920ee84c0126247184f0195480 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail009.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +p = [(1::Int)..(2::Integer)] diff --git a/ghc/tests/typecheck/should_fail/tcfail009.stderr b/ghc/tests/typecheck/should_fail/tcfail009.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8c62fbc85df4995d25af6a68857ca5d67e3e5dc7 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail009.stderr @@ -0,0 +1,10 @@ + +tcfail009.hs:3: Couldn't match the type + `PrelBase.Integer' against `PrelBase.Int' + Expected: `PrelBase.Int' + Inferred: `PrelBase.Integer' + In an arithmetic sequence: + `[(1 :: PrelBase.Int) .. (2 :: PrelBase.Integer)]' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail010.hs b/ghc/tests/typecheck/should_fail/tcfail010.hs new file mode 100644 index 0000000000000000000000000000000000000000..8b793355da2f1bb924ac2fffe1b52e117b0ded1d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail010.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +q = \ (y:z) -> z+2 diff --git a/ghc/tests/typecheck/should_fail/tcfail010.stderr b/ghc/tests/typecheck/should_fail/tcfail010.stderr new file mode 100644 index 0000000000000000000000000000000000000000..1e9fd848b4d1f666c6b2d0d756ae19d8f1f237ad --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail010.stderr @@ -0,0 +1,9 @@ + +tcfail010.hs:3: No instance for: `PrelBase.Num [taBD]' + arising from use of `PrelBase.+' at tcfail010.hs:3 + +tcfail010.hs:3: No instance for: `PrelBase.Num [taBD]' + arising from use of `PrelBase.+' at tcfail010.hs:3 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail011.hs b/ghc/tests/typecheck/should_fail/tcfail011.hs new file mode 100644 index 0000000000000000000000000000000000000000..89f5c4bcd1eb1de97fb50cbc86ce45ff43ec29b1 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail011.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +z = \y -> x x where x = y diff --git a/ghc/tests/typecheck/should_fail/tcfail011.stderr b/ghc/tests/typecheck/should_fail/tcfail011.stderr new file mode 100644 index 0000000000000000000000000000000000000000..636731270fb086072f8e804832a464a6084f92e9 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail011.stderr @@ -0,0 +1,5 @@ + +tcfail011.hs:3: Value not in scope: `y' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail012.hs b/ghc/tests/typecheck/should_fail/tcfail012.hs new file mode 100644 index 0000000000000000000000000000000000000000..67e5fa02568734c2edd84a23e3f73b7f0b42457a --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail012.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +True = [] diff --git a/ghc/tests/typecheck/should_fail/tcfail012.stderr b/ghc/tests/typecheck/should_fail/tcfail012.stderr new file mode 100644 index 0000000000000000000000000000000000000000..aefe17e9c48add68ec6709852a4a2bea27762c69 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail012.stderr @@ -0,0 +1,9 @@ + +tcfail012.hs:3: Couldn't match the type + `PrelBase.Bool' against `[tajU]' + Expected: `PrelBase.Bool' + Inferred: `[tajU]' + In a pattern binding: `PrelBase.True = PrelBase.[]' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail013.hs b/ghc/tests/typecheck/should_fail/tcfail013.hs new file mode 100644 index 0000000000000000000000000000000000000000..c9ccc52a64749f26873027ff8093d66331178f58 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail013.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +f [] = 1 +f True = 2 diff --git a/ghc/tests/typecheck/should_fail/tcfail013.stderr b/ghc/tests/typecheck/should_fail/tcfail013.stderr new file mode 100644 index 0000000000000000000000000000000000000000..eaf06c15933774d5d5b6d0fa4e55f4fb7ced015c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail013.stderr @@ -0,0 +1,9 @@ + +tcfail013.hs:4: Couldn't match the type + `[taBB]' against `PrelBase.Bool' + Expected: `[taBB] -> taBD' + Inferred: `PrelBase.Bool -> taBG' + In an equation for function `f': `f PrelBase.True = 2' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail014.hs b/ghc/tests/typecheck/should_fail/tcfail014.hs new file mode 100644 index 0000000000000000000000000000000000000000..7d9169936d6d19e7376ab7e230e255b5a8f06380 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail014.stderr b/ghc/tests/typecheck/should_fail/tcfail014.stderr new file mode 100644 index 0000000000000000000000000000000000000000..be4ae1fc8e8dddb6337a6781604974bdf987c5c7 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail014.stderr @@ -0,0 +1,18 @@ + +tcfail014.hs:5: Cannot construct the infinite type (occur check) + `oaBR' = `oaBR -> oaCz' + Expected: `oaBR' + Inferred: `oaBR -> oaCz' + In the first argument of `z', namely `z' + In an equation for function `h': `h z = z z' + In an equation for function `g': + `g y + = h PrelBase.+ 2 + where + h z = z z' + +tcfail014.hs:5: No instance for: `PrelBase.Num (taCk -> taCl)' + arising from use of `PrelBase.+' at tcfail014.hs:5 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail015.hs b/ghc/tests/typecheck/should_fail/tcfail015.hs new file mode 100644 index 0000000000000000000000000000000000000000..ae929e397379d8ac6bc641319d09336182d829b4 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail015.stderr b/ghc/tests/typecheck/should_fail/tcfail015.stderr new file mode 100644 index 0000000000000000000000000000000000000000..719e366d6599e689db8637e870fcdfa1d079bbf8 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail015.stderr @@ -0,0 +1,6 @@ + +tcfail015.hs:7: No instance for: `PrelBase.Num PrelBase.Bool' + arising from the literal 2 at tcfail015.hs:7 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail016.hs b/ghc/tests/typecheck/should_fail/tcfail016.hs new file mode 100644 index 0000000000000000000000000000000000000000..2dfd4a50e0a558c14b5b6cf219cc06191303584a --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail016.stderr b/ghc/tests/typecheck/should_fail/tcfail016.stderr new file mode 100644 index 0000000000000000000000000000000000000000..a08f8a06027eb2a2217be6e05b890e6f46b410b0 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail016.stderr @@ -0,0 +1,12 @@ + +tcfail016.hs:9: Couldn't match the type + `PrelTup.(,) taRi' against `Expr' + Expected: `Expr taRd' + Inferred: `AnnExpr taRi' + In the first argument of `g', namely `e1' + In the first argument of `PrelBase.++', namely `(g e1)' + In an equation for function `g': + `g (App e1 e2) = (g e1) PrelBase.++ (g e2)' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail017.hs b/ghc/tests/typecheck/should_fail/tcfail017.hs new file mode 100644 index 0000000000000000000000000000000000000000..db3215dc196a306fe3b4ad036b54c59d4fc7719e --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail017.stderr b/ghc/tests/typecheck/should_fail/tcfail017.stderr new file mode 100644 index 0000000000000000000000000000000000000000..be53d896817b23f8dc85343ef22724e8d67847f6 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail017.stderr @@ -0,0 +1,7 @@ + +tcfail017.hs:11: No instance for: `C [takz]' + arising from an instance declaration at tcfail017.hs:11 + When checking superclass constraints of an instance declaration + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail018.hs b/ghc/tests/typecheck/should_fail/tcfail018.hs new file mode 100644 index 0000000000000000000000000000000000000000..d91306ac553b6454726b08dbfd5264c4e34d7ffa --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail018.hs @@ -0,0 +1,5 @@ + + +module ShouldSucc where + +(a:[]) = 1 diff --git a/ghc/tests/typecheck/should_fail/tcfail018.stderr b/ghc/tests/typecheck/should_fail/tcfail018.stderr new file mode 100644 index 0000000000000000000000000000000000000000..987eb45ac6ac7418175e3543ae3e99e46f7e46e3 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail018.stderr @@ -0,0 +1,9 @@ + +tcfail018.hs:5: No instance for: `PrelBase.Num [taBB]' + arising from the literal 1 at tcfail018.hs:5 + +tcfail018.hs:5: No instance for: `PrelBase.Num [taBB]' + arising from the literal 1 at tcfail018.hs:5 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail019.hs b/ghc/tests/typecheck/should_fail/tcfail019.hs new file mode 100644 index 0000000000000000000000000000000000000000..b3da9cdebcba0b097cb993b191358b337fc8ec1c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail019.hs @@ -0,0 +1,21 @@ + +module P 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/ghc/tests/typecheck/should_fail/tcfail019.stderr b/ghc/tests/typecheck/should_fail/tcfail019.stderr new file mode 100644 index 0000000000000000000000000000000000000000..a5da89faf0ac61a5eec9b62bcff5c65bdcf2cb29 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail019.stderr @@ -0,0 +1,19 @@ + +tcfail019.hs:20: No instance for: `B [tal6]' + arising from an instance declaration at tcfail019.hs:20 + When checking methods of an instance declaration + +tcfail019.hs:20: No instance for: `C [tal6]' + arising from an instance declaration at tcfail019.hs:20 + When checking methods of an instance declaration + +tcfail019.hs:20: No instance for: `B [tal6]' + arising from an instance declaration at tcfail019.hs:20 + When checking superclass constraints of an instance declaration + +tcfail019.hs:20: No instance for: `C [tal6]' + arising from an instance declaration at tcfail019.hs:20 + When checking superclass constraints of an instance declaration + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail020.hs b/ghc/tests/typecheck/should_fail/tcfail020.hs new file mode 100644 index 0000000000000000000000000000000000000000..9697838fb1c2c396fcad4d38a065d7c0be2e21bd --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail020.hs @@ -0,0 +1,17 @@ + +module P 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/ghc/tests/typecheck/should_fail/tcfail020.stderr b/ghc/tests/typecheck/should_fail/tcfail020.stderr new file mode 100644 index 0000000000000000000000000000000000000000..ac622837bb54ca798305fa6ebc4c2a9db482886c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail020.stderr @@ -0,0 +1,7 @@ + +tcfail020.hs:12: No instance for: `A [taBn]' + arising from an instance declaration at tcfail020.hs:12 + When checking superclass constraints of an instance declaration + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail021.hs b/ghc/tests/typecheck/should_fail/tcfail021.hs new file mode 100644 index 0000000000000000000000000000000000000000..de18ba58a9d6bf24972fc1f384c5ddd03d3dabf5 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail023.hs b/ghc/tests/typecheck/should_fail/tcfail023.hs new file mode 100644 index 0000000000000000000000000000000000000000..ae2a3564610a6f4922a3aec719673d37046a7e05 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail023.hs @@ -0,0 +1,13 @@ + +data B = C + +class A a where + op :: a -> a + +instance A B where + op C = True + +instance A B where + op C = True + + diff --git a/ghc/tests/typecheck/should_fail/tcfail023.stderr b/ghc/tests/typecheck/should_fail/tcfail023.stderr new file mode 100644 index 0000000000000000000000000000000000000000..f17c04ff6ea985d884301647cd63f15dae2d0640 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail023.stderr @@ -0,0 +1,19 @@ + +tcfail023.hs:2: Duplicate or overlapping instance declarations + for `A B' at tcfail023.hs:8 and tcfail023.hs:11 + +tcfail023.hs:11: Couldn't match the type + `B' against `PrelBase.Bool' + Expected: `B' + Inferred: `PrelBase.Bool' + In an equation for function `op': `op C = PrelBase.True' + +tcfail023.hs:8: Couldn't match the type `B' against `PrelBase.Bool' + Expected: `B' + Inferred: `PrelBase.Bool' + In an equation for function `op': `op C = PrelBase.True' + +tcfail023.hs:2: Module Main must include a definition for `Main.main' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail025.stderr b/ghc/tests/typecheck/should_fail/tcfail025.stderr new file mode 100644 index 0000000000000000000000000000000000000000..6a0f830cc4c1d692981d444b0029e42a590a90cc --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail026.stderr b/ghc/tests/typecheck/should_fail/tcfail026.stderr new file mode 100644 index 0000000000000000000000000000000000000000..23e90f7ae429efb8d5dec5a8a59d7a4b848ab88c --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail027.hs b/ghc/tests/typecheck/should_fail/tcfail027.hs new file mode 100644 index 0000000000000000000000000000000000000000..b80430ba26e7279ee5836342c625fa135b05119e --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail027.hs @@ -0,0 +1,7 @@ +--!!! tests for CycleErr in classes + +class (B a) => A a where + op1 :: a -> a + +class (A a) => B a where + op2 :: a -> a -> a diff --git a/ghc/tests/typecheck/should_fail/tcfail027.stderr b/ghc/tests/typecheck/should_fail/tcfail027.stderr new file mode 100644 index 0000000000000000000000000000000000000000..617dd4b68b219cd86cb7589eace03af38331c7ca --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail027.stderr @@ -0,0 +1,7 @@ + +tcfail027.hs:3: Cycle in class declarations ... + `A' tcfail027.hs:4 + `B' tcfail027.hs:7 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail028.hs b/ghc/tests/typecheck/should_fail/tcfail028.hs new file mode 100644 index 0000000000000000000000000000000000000000..8e8c2946a0841c3f383033a36afb084fac2ddd2b --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail028.hs @@ -0,0 +1,3 @@ +--!!! tests for ArityErr + +data A a b = B (A a) diff --git a/ghc/tests/typecheck/should_fail/tcfail028.stderr b/ghc/tests/typecheck/should_fail/tcfail028.stderr new file mode 100644 index 0000000000000000000000000000000000000000..b41cd3692ac559c503d23e5e6e78cf39b54b39fd --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail028.stderr @@ -0,0 +1,7 @@ + +tcfail028.hs:4: Couldn't match the kind `ka2534 -> *' against `*' + When unifying two kinds `ka2534 -> *' and `*' + In the data declaration for `A' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail029.hs b/ghc/tests/typecheck/should_fail/tcfail029.hs new file mode 100644 index 0000000000000000000000000000000000000000..4b8f2c6c891bad4a96f06daf0b51249218ce595c --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail029.stderr b/ghc/tests/typecheck/should_fail/tcfail029.stderr new file mode 100644 index 0000000000000000000000000000000000000000..a431a6592f2438f886c1c313aa812012da1c0c70 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail029.stderr @@ -0,0 +1,6 @@ + +tcfail029.hs:6: No instance for: `PrelBase.Ord Foo' + arising from use of `PrelBase.>' at tcfail029.hs:6 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail030.hs b/ghc/tests/typecheck/should_fail/tcfail030.hs new file mode 100644 index 0000000000000000000000000000000000000000..2aa8659940a0f160e271d7ebfab100fddc33a7f8 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail030.hs @@ -0,0 +1 @@ +--!!! empty file diff --git a/ghc/tests/typecheck/should_fail/tcfail030.stderr b/ghc/tests/typecheck/should_fail/tcfail030.stderr new file mode 100644 index 0000000000000000000000000000000000000000..3dbe460a581cd5cd4dd3ede626c7d7b5f016837a --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail030.stderr @@ -0,0 +1,5 @@ + +tcfail030.hs:0: Module Main must include a definition for `Main.main' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail031.hs b/ghc/tests/typecheck/should_fail/tcfail031.hs new file mode 100644 index 0000000000000000000000000000000000000000..6b9a0de12b89ec8db84514e11875502f81b3cfcc --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail031.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = if 'a' then 1 else 2 diff --git a/ghc/tests/typecheck/should_fail/tcfail031.stderr b/ghc/tests/typecheck/should_fail/tcfail031.stderr new file mode 100644 index 0000000000000000000000000000000000000000..bcc5bde8b5419b410bd49d86f4fd1d95cf171097 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail031.stderr @@ -0,0 +1,10 @@ + +tcfail031.hs:3: Couldn't match the type + `PrelBase.Bool' against `PrelBase.Char' + Expected: `PrelBase.Bool' + Inferred: `PrelBase.Char' + In the predicate expression `'a'' + In an equation for function `f': `f x = if 'a' then 1 else 2' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail032.hs b/ghc/tests/typecheck/should_fail/tcfail032.hs new file mode 100644 index 0000000000000000000000000000000000000000..0e8884da3fe754d3f3deb3ec6f7f6c64e01f0b09 --- /dev/null +++ b/ghc/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 TcSig where + +f x = (x :: (Eq a) => a -> Int) + + diff --git a/ghc/tests/typecheck/should_fail/tcfail032.stderr b/ghc/tests/typecheck/should_fail/tcfail032.stderr new file mode 100644 index 0000000000000000000000000000000000000000..c947b0bdfb0f50abc5ae6f048edacbcd011ded3d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail032.stderr @@ -0,0 +1,10 @@ + +tcfail032.hs:14: A type signature is more polymorphic than the inferred type + Some type variables in the inferred type can't be forall'd, namely: + `taAx' + Possible cause: the RHS mentions something subject to the monomorphism restriction + In an expression with a type signature: + `x :: _forall_ [a] (PrelBase.Eq a) => a -> PrelBase.Int' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail033.hs b/ghc/tests/typecheck/should_fail/tcfail033.hs new file mode 100644 index 0000000000000000000000000000000000000000..fdc0aff8ed5a1ce0d349e6dfdaa51148149a8bf1 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail033.hs @@ -0,0 +1,4 @@ +-- from Jon Hill +module ShouldFail where + +buglet = [ x | (x,y) <- buglet ] diff --git a/ghc/tests/typecheck/should_fail/tcfail033.stderr b/ghc/tests/typecheck/should_fail/tcfail033.stderr new file mode 100644 index 0000000000000000000000000000000000000000..68a79648192cde2bdc1a22cd3fcc59052a629def --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail033.stderr @@ -0,0 +1,9 @@ + +tcfail033.hs:4: Cannot construct the infinite type (occur check) + `taGt' = `(taGt, taGw)' + Expected: `aaGy (taGt, taGw)' + Inferred: `aaGy taGt' + In a pattern binding: `buglet = [ x | (x, y) <- buglet ]' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail034.hs b/ghc/tests/typecheck/should_fail/tcfail034.hs new file mode 100644 index 0000000000000000000000000000000000000000..82aa18b41872cc2446c25314d973d24f73f7daef --- /dev/null +++ b/ghc/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 ShouldSucceed 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/ghc/tests/typecheck/should_fail/tcfail034.stderr b/ghc/tests/typecheck/should_fail/tcfail034.stderr new file mode 100644 index 0000000000000000000000000000000000000000..48b168a2961212ad1f7866eee3f955c448330165 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail034.stderr @@ -0,0 +1,8 @@ + +tcfail034.hs:13: Context `{PrelNum.Integral taTL}' + required by inferred type, but missing on a type signature + `PrelNum.Integral' `taTL' arising from use of `PrelNum.mod' at tcfail034.hs:17 + When checking signature(s) for: `test' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail035.hs b/ghc/tests/typecheck/should_fail/tcfail035.hs new file mode 100644 index 0000000000000000000000000000000000000000..a12908ee5a246ed9f0ede3b95b7a6baa2aba0d6f --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail035.hs @@ -0,0 +1,9 @@ +--!!! instances with empty where parts: duplicate +-- +module M where + +data NUM = ONE | TWO +instance Num NUM +instance Num NUM +instance Eq NUM +instance Show NUM diff --git a/ghc/tests/typecheck/should_fail/tcfail035.stderr b/ghc/tests/typecheck/should_fail/tcfail035.stderr new file mode 100644 index 0000000000000000000000000000000000000000..d1cc37462400cf1c5f8a6d476691b4abf32db2e3 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail035.stderr @@ -0,0 +1,47 @@ + +tcfail035.hs:3: Duplicate or overlapping instance declarations + for `PrelBase.Num NUM' at tcfail035.hs:6 and tcfail035.hs:7 + +tcfail035.hs:9: No explicit method nor default method for `PrelBase.showsPrec' + in an instance declaration for `PrelBase.Show' + +tcfail035.hs:8: No explicit method nor default method for `PrelBase.==' + in an instance declaration for `PrelBase.Eq' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.+' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.*' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.negate' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.abs' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.signum' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:7: No explicit method nor default method for `PrelBase.fromInteger' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.+' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.*' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.negate' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.abs' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.signum' + in an instance declaration for `PrelBase.Num' + +tcfail035.hs:6: No explicit method nor default method for `PrelBase.fromInteger' + in an instance declaration for `PrelBase.Num' + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail036.hs b/ghc/tests/typecheck/should_fail/tcfail036.hs new file mode 100644 index 0000000000000000000000000000000000000000..eb9f9aff85b8767fb1670d1160385c4dc7559f46 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail036.hs @@ -0,0 +1,10 @@ +--!!! prelude class name in an instance-tycon position +-- +module M where + +data NUM = ONE | TWO +instance Num NUM + where ONE + ONE = TWO +instance Num NUM +instance Eq Num +--instance Text Num diff --git a/ghc/tests/typecheck/should_fail/tcfail036.stderr b/ghc/tests/typecheck/should_fail/tcfail036.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8fdfea4bdf3f0fbd2f2e8d234a1a02203397ec18 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail036.stderr @@ -0,0 +1,72 @@ + +tcfail036.hs:9: Class used as a type constructor: `PrelBase.Num' + +tcfail036.hs:3: Duplicate or overlapping instance declarations + for `PrelBase.Num NUM' at tcfail036.hs:7 and tcfail036.hs:8 + +tcfail036.hs:8: No instance for: `PrelBase.Eq NUM' + arising from an instance declaration at tcfail036.hs:8 + When checking methods of an instance declaration + +tcfail036.hs:8: No instance for: `PrelBase.Show NUM' + arising from an instance declaration at tcfail036.hs:8 + When checking methods of an instance declaration + +tcfail036.hs:8: No instance for: `PrelBase.Eq NUM' + arising from an instance declaration at tcfail036.hs:8 + When checking superclass constraints of an instance declaration + +tcfail036.hs:8: No instance for: `PrelBase.Show NUM' + arising from an instance declaration at tcfail036.hs:8 + When checking superclass constraints of an instance declaration + +tcfail036.hs:7: No instance for: `PrelBase.Eq NUM' + arising from an instance declaration at tcfail036.hs:7 + When checking methods of an instance declaration + +tcfail036.hs:7: No instance for: `PrelBase.Show NUM' + arising from an instance declaration at tcfail036.hs:7 + When checking methods of an instance declaration + +tcfail036.hs:7: No instance for: `PrelBase.Eq NUM' + arising from an instance declaration at tcfail036.hs:7 + When checking superclass constraints of an instance declaration + +tcfail036.hs:7: No instance for: `PrelBase.Show NUM' + arising from an instance declaration at tcfail036.hs:7 + When checking superclass constraints of an instance declaration + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.+' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.*' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.negate' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.abs' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.signum' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:8: No explicit method nor default method for `PrelBase.fromInteger' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:7: No explicit method nor default method for `PrelBase.*' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:7: No explicit method nor default method for `PrelBase.negate' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:7: No explicit method nor default method for `PrelBase.abs' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:7: No explicit method nor default method for `PrelBase.signum' + in an instance declaration for `PrelBase.Num' + +tcfail036.hs:7: No explicit method nor default method for `PrelBase.fromInteger' + in an instance declaration for `PrelBase.Num' + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail037.hs b/ghc/tests/typecheck/should_fail/tcfail037.hs new file mode 100644 index 0000000000000000000000000000000000000000..07b308b98cc357bc8befc1f494d4abf435f41c93 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail037.hs @@ -0,0 +1,11 @@ +--!!! PreludeCore entities cannot be redefined at the top-level +-- +module M where + +data NUM = ONE | TWO + +f a b = a + b +f :: NUM -> NUM -> NUM + +ONE + ONE = TWO + diff --git a/ghc/tests/typecheck/should_fail/tcfail037.stderr b/ghc/tests/typecheck/should_fail/tcfail037.stderr new file mode 100644 index 0000000000000000000000000000000000000000..17d7580727892ff4db5a24d6d06fca181340d0a5 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail037.stderr @@ -0,0 +1,8 @@ + +tcfail037.hs:3: + Conflicting definitions for: `+' + Imported from Prelude at tcfail037.hs:3 + Defined at tcfail037.hs:10 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail038.hs b/ghc/tests/typecheck/should_fail/tcfail038.hs new file mode 100644 index 0000000000000000000000000000000000000000..7d03529a4e787831c6818b2f566c6b399c762fd9 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail038.hs @@ -0,0 +1,11 @@ +--!!! duplicate class-method declarations + +module M where + +data NUM = ONE | TWO +instance Eq NUM where + a == b = True + a /= b = False + a == b = False + a /= b = True + diff --git a/ghc/tests/typecheck/should_fail/tcfail038.stderr b/ghc/tests/typecheck/should_fail/tcfail038.stderr new file mode 100644 index 0000000000000000000000000000000000000000..84e74e123d47108756b2f5c7f8b47bd58d1d6737 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail038.stderr @@ -0,0 +1,9 @@ + +tcfail038.hs:8: + Conflicting definitions for `/=' in the bindings in an instance declaration + +tcfail038.hs:7: + Conflicting definitions for `==' in the bindings in an instance declaration + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail039.hs b/ghc/tests/typecheck/should_fail/tcfail039.hs new file mode 100644 index 0000000000000000000000000000000000000000..f0df10c28712da89ec5cab0205395e2d552c2ec5 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail039.hs @@ -0,0 +1,12 @@ +--!!! bogus re-use of prelude class-method name (==) +-- +module M where + +data NUM = ONE | TWO +class EQ a where + (==) :: a -> a -> Bool + +instance EQ NUM +-- a /= b = False +-- a == b = True +-- a /= b = False diff --git a/ghc/tests/typecheck/should_fail/tcfail039.stderr b/ghc/tests/typecheck/should_fail/tcfail039.stderr new file mode 100644 index 0000000000000000000000000000000000000000..497555cc8c21de239f0b7e6a568691cfec103228 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail039.stderr @@ -0,0 +1,8 @@ + +tcfail039.hs:3: + Conflicting definitions for: `==' + Imported from Prelude at tcfail039.hs:3 + Defined at tcfail039.hs:7 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail040.hs b/ghc/tests/typecheck/should_fail/tcfail040.hs new file mode 100644 index 0000000000000000000000000000000000000000..c611518ee4ab606bea2dec148d1174f4db5ed505 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail040.hs @@ -0,0 +1,29 @@ +--!!! instances of functions +-- +module M 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/ghc/tests/typecheck/should_fail/tcfail040.stderr b/ghc/tests/typecheck/should_fail/tcfail040.stderr new file mode 100644 index 0000000000000000000000000000000000000000..b3fe51821eaeeee96da9e5a4fa28cc45713880d2 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail040.stderr @@ -0,0 +1,6 @@ + +tcfail040.hs:3: Ambiguous context `{ORD taBu}' + `ORD' `taBu' arising from use of `<<' at tcfail040.hs:19 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail042.hs b/ghc/tests/typecheck/should_fail/tcfail042.hs new file mode 100644 index 0000000000000000000000000000000000000000..37c24936a99607b27e61485cfbffe02d840e60e8 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail042.hs @@ -0,0 +1,28 @@ +--!!! 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/ghc/tests/typecheck/should_fail/tcfail042.stderr b/ghc/tests/typecheck/should_fail/tcfail042.stderr new file mode 100644 index 0000000000000000000000000000000000000000..2f0c83713928043e0158082118d46beab1bac714 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail042.stderr @@ -0,0 +1,10 @@ + +tcfail042.hs:16: Context `{PrelBase.Num taHh}' + required by inferred type, but missing on a type signature + `PrelBase.Num' `taHh' arising from an instance declaration at tcfail042.hs:16 + When checking superclass constraints of an instance declaration + +tcfail042.hs:4: Module Main must include a definition for `Main.main' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail043.hs b/ghc/tests/typecheck/should_fail/tcfail043.hs new file mode 100644 index 0000000000000000000000000000000000000000..cc1983be5bad77fc31e31f45c96a7f98443f0cd0 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail043.hs @@ -0,0 +1,222 @@ +-- 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) + + + +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 and (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) + +and :: Bool -> Bool -> Bool +and True True = True + +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 + +null :: [a] -> Bool +null [] = 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/ghc/tests/typecheck/should_fail/tcfail043.stderr b/ghc/tests/typecheck/should_fail/tcfail043.stderr new file mode 100644 index 0000000000000000000000000000000000000000..ad7df7227572509c4919669086d04c7384077ac0 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail043.stderr @@ -0,0 +1,13 @@ + +tcfail043.hs:16: + Conflicting definitions for: `and' + Imported from Prelude at tcfail043.hs:16 + Defined at tcfail043.hs:42 + +tcfail043.hs:16: + Conflicting definitions for: `null' + Imported from Prelude at tcfail043.hs:16 + Defined at tcfail043.hs:57 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail044.hs b/ghc/tests/typecheck/should_fail/tcfail044.hs new file mode 100644 index 0000000000000000000000000000000000000000..3f899a6f6b883b0c1394ee243cb73a404aa779b2 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail044.hs @@ -0,0 +1,22 @@ +--!!! tcfail044: duplicated type variable in instance decls +-- +module Main where + +instance (Eq a) => Eq (a->a) + + +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/ghc/tests/typecheck/should_fail/tcfail044.stderr b/ghc/tests/typecheck/should_fail/tcfail044.stderr new file mode 100644 index 0000000000000000000000000000000000000000..018a55a15df497eb4a3cfa95b24276e8a668ee88 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail044.stderr @@ -0,0 +1,13 @@ + +tcfail044.hs:12: The type `a + -> a' cannot be used as an instance type + +tcfail044.hs:5: The type `a + -> a' cannot be used as an instance type + +tcfail044.hs:20: No instance for: + `PrelBase.Num (PrelBase.Float -> PrelBase.Float)' + arising from use of `PrelBase.+' at tcfail044.hs:20 + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail045.hs b/ghc/tests/typecheck/should_fail/tcfail045.hs new file mode 100644 index 0000000000000000000000000000000000000000..b189d40077e078900c3fa5db54930a5c5d7c43e4 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail045.hs @@ -0,0 +1,11 @@ +--!!! a bad _CCallable thing (from a bug from Satnam) +-- +module ShouldSucceed where + +import Foreign + +data Socket = Socket# Addr +instance CCallable Socket + +f :: Socket -> PrimIO () +f x = _ccall_ foo x diff --git a/ghc/tests/typecheck/should_fail/tcfail045.stderr b/ghc/tests/typecheck/should_fail/tcfail045.stderr new file mode 100644 index 0000000000000000000000000000000000000000..d2920bdc7e91d22a23cbc24d0f57b3851d7da640 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail045.stderr @@ -0,0 +1,5 @@ + +tcfail045.hs:10: Type constructor or class not in scope: `PrimIO' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail046.hs b/ghc/tests/typecheck/should_fail/tcfail046.hs new file mode 100644 index 0000000000000000000000000000000000000000..40fad6ba7d4a99bfeb125f921e0e2aafe0bfa70b --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail046.hs @@ -0,0 +1,32 @@ +--!! function types in deriving Eq things +-- From a bug report by Dave Harrison <D.A.Harrison@newcastle.ac.uk> + +module Simulation(Process, + Status, + Pid, + Time, + Continuation, + Message, + MessList ) 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/ghc/tests/typecheck/should_fail/tcfail046.stderr b/ghc/tests/typecheck/should_fail/tcfail046.stderr new file mode 100644 index 0000000000000000000000000000000000000000..f83ce4321d4903e6e03f5026a7e5b1f23b8986fb --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail046.stderr @@ -0,0 +1,31 @@ + +tcfail046.hs:4: No instance for class + `PrelBase.Eq' + at type + `Process a' + +tcfail046.hs:4: No instance for class + `PrelBase.Eq' + at type + `Process a' + +tcfail046.hs:4: No instance for class + `PrelBase.Eq' + at type + `Process a' + +tcfail046.hs:4: No instance for class + `PrelBase.Eq' + at type + `Process a' + +tcfail046.hs:23: No instance for: `PrelBase.Eq (Process taVO)' + arising from use of `PrelBase.==' at tcfail046.hs:23 + When checking methods of an instance declaration + +tcfail046.hs:15: No instance for: `PrelBase.Eq (Process taZ8)' + arising from use of `PrelBase.==' at tcfail046.hs:15 + When checking methods of an instance declaration + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail047.hs b/ghc/tests/typecheck/should_fail/tcfail047.hs new file mode 100644 index 0000000000000000000000000000000000000000..12770a33eb2fbc8de61354bb27bb672b5e20bb1d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail047.hs @@ -0,0 +1,6 @@ + +class A a where + op1 :: a -> a + +instance A (a,(b,c)) where + op1 a = a diff --git a/ghc/tests/typecheck/should_fail/tcfail047.stderr b/ghc/tests/typecheck/should_fail/tcfail047.stderr new file mode 100644 index 0000000000000000000000000000000000000000..6df94a6b5ec86b49b22abab576bc304137a0fdf2 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail047.stderr @@ -0,0 +1,7 @@ + +tcfail047.hs:6: The type `(a, (b, c))' cannot be used as an instance type + +tcfail047.hs:2: Module Main must include a definition for `Main.main' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail048.hs b/ghc/tests/typecheck/should_fail/tcfail048.hs new file mode 100644 index 0000000000000000000000000000000000000000..f4400e2fa01cd72211ee78262ecefd9f9f218186 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail048.stderr b/ghc/tests/typecheck/should_fail/tcfail048.stderr new file mode 100644 index 0000000000000000000000000000000000000000..fd7bc0bf7f7d0e2298f6e51c710e5804a89c962e --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail048.stderr @@ -0,0 +1,5 @@ + +tcfail048.hs:4: Type constructor or class not in scope: `B' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail049.hs b/ghc/tests/typecheck/should_fail/tcfail049.hs new file mode 100644 index 0000000000000000000000000000000000000000..64dee54a5c9623bbaa97b3666e1ae46ce04e8d77 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail049.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = g x diff --git a/ghc/tests/typecheck/should_fail/tcfail049.stderr b/ghc/tests/typecheck/should_fail/tcfail049.stderr new file mode 100644 index 0000000000000000000000000000000000000000..972ab29272dcdb12297d41016acd1b3b775860e9 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail049.stderr @@ -0,0 +1,5 @@ + +tcfail049.hs:3: Value not in scope: `g' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail050.hs b/ghc/tests/typecheck/should_fail/tcfail050.hs new file mode 100644 index 0000000000000000000000000000000000000000..c0cee979f7e4ec1f3399d1b9c131c7bf9f84561a --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail050.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = B x diff --git a/ghc/tests/typecheck/should_fail/tcfail050.stderr b/ghc/tests/typecheck/should_fail/tcfail050.stderr new file mode 100644 index 0000000000000000000000000000000000000000..e468e080fd82e975f82cb0351c17c25c8823330c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail050.stderr @@ -0,0 +1,5 @@ + +tcfail050.hs:3: Data constructor not in scope: `B' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail051.hs b/ghc/tests/typecheck/should_fail/tcfail051.hs new file mode 100644 index 0000000000000000000000000000000000000000..1b8e251c4083de3e28b34c7b7c0eaf6a25b57788 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail051.hs @@ -0,0 +1,4 @@ +module ShouldFail where + +instance B Bool where + op1 a = a diff --git a/ghc/tests/typecheck/should_fail/tcfail051.stderr b/ghc/tests/typecheck/should_fail/tcfail051.stderr new file mode 100644 index 0000000000000000000000000000000000000000..9f4e645b2da54f2fc3d4e5fb745d516f97f8c79e --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail051.stderr @@ -0,0 +1,5 @@ + +tcfail051.hs:4: Type constructor or class not in scope: `B' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail052.hs b/ghc/tests/typecheck/should_fail/tcfail052.hs new file mode 100644 index 0000000000000000000000000000000000000000..e9be21e6f2b2ad99d5e27c830e9c238b12ca6ed9 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail052.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +data C a = B a c diff --git a/ghc/tests/typecheck/should_fail/tcfail052.stderr b/ghc/tests/typecheck/should_fail/tcfail052.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8f1508967b46e35846ae8054936f3dca7e07ac84 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail052.stderr @@ -0,0 +1,5 @@ + +tcfail052.hs:4: Type variable not in scope: `c' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail053.hs b/ghc/tests/typecheck/should_fail/tcfail053.hs new file mode 100644 index 0000000000000000000000000000000000000000..99028ab4c8cb49817d1738e7f482a15053eb1121 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail053.hs @@ -0,0 +1,2 @@ + +data B = C A diff --git a/ghc/tests/typecheck/should_fail/tcfail053.stderr b/ghc/tests/typecheck/should_fail/tcfail053.stderr new file mode 100644 index 0000000000000000000000000000000000000000..6c9d899f2972512e2c0c3f1db13ce1eb46653f65 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail053.stderr @@ -0,0 +1,5 @@ + +tcfail053.hs:3: Type constructor or class not in scope: `A' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail054.hs b/ghc/tests/typecheck/should_fail/tcfail054.hs new file mode 100644 index 0000000000000000000000000000000000000000..a4e724cf18a2f7ccc9f913ba1733caa87f854eda --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail054.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f (B a) = True diff --git a/ghc/tests/typecheck/should_fail/tcfail054.stderr b/ghc/tests/typecheck/should_fail/tcfail054.stderr new file mode 100644 index 0000000000000000000000000000000000000000..a2dc363e5c0bfe0d97831daa1d2261cc7edf1c53 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail054.stderr @@ -0,0 +1,5 @@ + +tcfail054.hs:3: Data constructor not in scope: `B' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail055.hs b/ghc/tests/typecheck/should_fail/tcfail055.hs new file mode 100644 index 0000000000000000000000000000000000000000..f61c5a81be72f69d0ac0e99fa2fc63ff1d7d1602 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail055.hs @@ -0,0 +1,3 @@ +module ShouldFail where + +f x = (x + 1 :: Int) :: Float diff --git a/ghc/tests/typecheck/should_fail/tcfail055.stderr b/ghc/tests/typecheck/should_fail/tcfail055.stderr new file mode 100644 index 0000000000000000000000000000000000000000..8070c1793781762cfcab32a6541939a0b2069773 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail055.stderr @@ -0,0 +1,10 @@ + +tcfail055.hs:3: Couldn't match the type + `PrelBase.Int' against `PrelBase.Float' + Expected: `PrelBase.Float' + Inferred: `PrelBase.Int' + In an expression with a type signature: + `(x PrelBase.+ 1 :: PrelBase.Int) :: PrelBase.Float' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail056.hs b/ghc/tests/typecheck/should_fail/tcfail056.hs new file mode 100644 index 0000000000000000000000000000000000000000..a8a1315be781a33d07815c866d7c4cc831415a90 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail056.stderr b/ghc/tests/typecheck/should_fail/tcfail056.stderr new file mode 100644 index 0000000000000000000000000000000000000000..7939827addcc8053953ae7aad970c4ffd7b20f5d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail056.stderr @@ -0,0 +1,10 @@ + +tcfail056.hs:1: Duplicate or overlapping instance declarations + for `PrelBase.Eq Foo' at tcfail056.hs:6 and tcfail056.hs:10 + +tcfail056.hs:10: Class `PrelBase.Eq' does not have a method `<=' + +tcfail056.hs:10: No explicit method nor default method for `PrelBase.==' + in an instance declaration for `PrelBase.Eq' + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail057.hs b/ghc/tests/typecheck/should_fail/tcfail057.hs new file mode 100644 index 0000000000000000000000000000000000000000..bef0085fe5427bb7569712affb677c1d6002e582 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail057.stderr b/ghc/tests/typecheck/should_fail/tcfail057.stderr new file mode 100644 index 0000000000000000000000000000000000000000..96199e7f135720ba1b7f0588b9f058e89724fec5 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail057.stderr @@ -0,0 +1,5 @@ + +tcfail057.hs:5: Class used as a type constructor: `PrelNum.RealFrac' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail058.hs b/ghc/tests/typecheck/should_fail/tcfail058.hs new file mode 100644 index 0000000000000000000000000000000000000000..c05c85972f9671d6820a652ece52a62dadb84675 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail058.hs @@ -0,0 +1,7 @@ +module ShouldFail where +import Array + +--!!! inadvertently using => instead of -> + +f :: (Array a) => a -> b +f x = x diff --git a/ghc/tests/typecheck/should_fail/tcfail058.stderr b/ghc/tests/typecheck/should_fail/tcfail058.stderr new file mode 100644 index 0000000000000000000000000000000000000000..d771e0e3cf906817af689690643b292642ce3f64 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail058.stderr @@ -0,0 +1,5 @@ + +tcfail058.hs:6: Type constructor used as a class: `ArrBase.Array' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail061.hs b/ghc/tests/typecheck/should_fail/tcfail061.hs new file mode 100644 index 0000000000000000000000000000000000000000..2957e800d5d3aaa776e7f0a16cafafcf43e69082 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail061.hs @@ -0,0 +1,11 @@ +--!! signature bugs exposed by Sigbjorne 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/ghc/tests/typecheck/should_fail/tcfail061.stderr b/ghc/tests/typecheck/should_fail/tcfail061.stderr new file mode 100644 index 0000000000000000000000000000000000000000..bf0379483c5a6c527efa8dbbf918729252ec3f18 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail061.stderr @@ -0,0 +1,11 @@ + +tcfail061.hs:11: Type variable not in scope: `b' + +tcfail061.hs:11: Type variable not in scope: `b' + +tcfail061.hs:5: Type variable not in scope: `b' + +tcfail061.hs:5: Type variable not in scope: `b' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail062.hs b/ghc/tests/typecheck/should_fail/tcfail062.hs new file mode 100644 index 0000000000000000000000000000000000000000..5c9b0ea2156b7d765f3d90ecd167d42341222829 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail062.hs @@ -0,0 +1,37 @@ +--!!! bug report from Satnam +-- +module RubyAST +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/ghc/tests/typecheck/should_fail/tcfail062.stderr b/ghc/tests/typecheck/should_fail/tcfail062.stderr new file mode 100644 index 0000000000000000000000000000000000000000..7cffa7b5e3b571dec8d5f538910ac5fe78cb5be6 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail062.stderr @@ -0,0 +1,9 @@ + +tcfail062.hs:33: + Type variable not in scope: `behaviouralExpression' + +tcfail062.hs:33: + Type variable not in scope: `behaviouralExpression' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail063.hs b/ghc/tests/typecheck/should_fail/tcfail063.hs new file mode 100644 index 0000000000000000000000000000000000000000..562cdf4400cfe991d3318a889054f26bd38ef9dd --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail063.hs @@ -0,0 +1,5 @@ +--!!! no type variable on a context +--!!! reported by Sigbjorn Finne + +moby :: Num => Int -> a -> Int +moby x y = x+y diff --git a/ghc/tests/typecheck/should_fail/tcfail063.stderr b/ghc/tests/typecheck/should_fail/tcfail063.stderr new file mode 100644 index 0000000000000000000000000000000000000000..bdec0c873ca56ade98398a97bc9895a9b1168566 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail063.stderr @@ -0,0 +1 @@ +tcfail063.hs:5:1: is_context_format: variable missing after class name on input: "moby" diff --git a/ghc/tests/typecheck/should_fail/tcfail064.hs b/ghc/tests/typecheck/should_fail/tcfail064.hs new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ghc/tests/typecheck/should_fail/tcfail064.stderr b/ghc/tests/typecheck/should_fail/tcfail064.stderr new file mode 100644 index 0000000000000000000000000000000000000000..1709a477307b32ff09ab3ec64c2f26c9b9920679 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail064.stderr @@ -0,0 +1,5 @@ + +tcfail064.hs:0: Module Main must include a definition for `Main.main' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail065.hs b/ghc/tests/typecheck/should_fail/tcfail065.hs new file mode 100644 index 0000000000000000000000000000000000000000..3029b1978c46b93e524fc37b6192687d34b6ab65 --- /dev/null +++ b/ghc/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/ghc/tests/typecheck/should_fail/tcfail065.stderr b/ghc/tests/typecheck/should_fail/tcfail065.stderr new file mode 100644 index 0000000000000000000000000000000000000000..83fb883a6d165f52b7e5f7e089f5b8b2ea909835 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail065.stderr @@ -0,0 +1,9 @@ + +<NoSrcLoc>: A type signature is more polymorphic than the inferred type + Some type variables in the inferred type can't be forall'd, namely: + `taHR' + Possible cause: the RHS mentions something subject to the monomorphism restriction + When checking signature for `setX' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail067.hs b/ghc/tests/typecheck/should_fail/tcfail067.hs new file mode 100644 index 0000000000000000000000000000000000000000..99d4c648c06a8f15ffae96d889d82cafff89ac40 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail067.hs @@ -0,0 +1,98 @@ +module SubRange 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/ghc/tests/typecheck/should_fail/tcfail067.stderr b/ghc/tests/typecheck/should_fail/tcfail067.stderr new file mode 100644 index 0000000000000000000000000000000000000000..392680b3e91cb631758062acb0853723ad4d820c --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail067.stderr @@ -0,0 +1,18 @@ + +tcfail067.hs:1: Context `{PrelBase.Ord ta17k}' + required by inferred type, but missing on a type signature + `PrelBase.Ord' `ta17k' arising from use of `SubRange' at tcfail067.hs:76 + When checking signature(s) for: `numSubRangeBinOp' + +tcfail067.hs:65: Context `{PrelBase.Ord ta18S}' + required by inferred type, but missing on a type signature + `PrelBase.Ord' `ta18S' arising from use of `numSubRangeNegate' at tcfail067.hs:61 + When checking methods of an instance declaration + +tcfail067.hs:65: No explicit method nor default method for `PrelBase.abs' + in an instance declaration for `PrelBase.Num' + +tcfail067.hs:65: No explicit method nor default method for `PrelBase.signum' + in an instance declaration for `PrelBase.Num' + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail068.hs b/ghc/tests/typecheck/should_fail/tcfail068.hs new file mode 100644 index 0000000000000000000000000000000000000000..d24354063458972e0c58712f70c11f9dace848f3 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail068.hs @@ -0,0 +1,92 @@ +--!! Make sure that state threads don't escape +--!! (example from Neil Ashton at York) +-- +module IndTree(IndTree(..), itgen, itiap, itrap, itrapstate) where + +import GlaExts +import ST + +type IndTree s t = MutableArray s (Int,Int) t + +itgen :: Constructed a => (Int,Int) -> a -> IndTree s a +itgen n x = + runST ( + newArray ((1,1),n) x) + +itiap :: Constructed a => (Int,Int) -> (a->a) -> IndTree s a -> IndTree s a +itiap i f arr = + runST ( + readArray arr i `thenStrictlyST` \val -> + writeArray arr i (f val) `seqStrictlyST` + returnStrictlyST 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 returnStrictlyST arr + else (itrapsnd i k `seqStrictlyST` + itrap' i (k+1)) + itrapsnd i k = if i > j then returnStrictlyST arr + else (readArray arr (i,k) `thenStrictlyST` \val -> + writeArray arr (i,k) (f val) `seqStrictlyST` + 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 returnStrictlyST (s,arr) + else (itrapstatesnd i k s `thenStrictlyST` \(s,arr) -> + itrapstate' i (k+1) s) + itrapstatesnd i k s = if i > j then returnStrictlyST (s,arr) + else (readArray arr (i,k) `thenStrictlyST` \val -> + let (newstate, newval) = f (c (i,k) s) val + in writeArray arr (i,k) newval `seqStrictlyST` + 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 + +data Maybe t = Just t | Nothing + +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/ghc/tests/typecheck/should_fail/tcfail068.stderr b/ghc/tests/typecheck/should_fail/tcfail068.stderr new file mode 100644 index 0000000000000000000000000000000000000000..26dc356907132fb57c36ef21d6aebaa0c984bc97 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail068.stderr @@ -0,0 +1,44 @@ + +tcfail068.hs:4: + Conflicting definitions for: `Just' + Imported from Prelude at tcfail068.hs:4 + Defined at tcfail068.hs:68 + +tcfail068.hs:4: + Conflicting definitions for: `Nothing' + Imported from Prelude at tcfail068.hs:4 + Defined at tcfail068.hs:70 + +tcfail068.hs:4: + Conflicting definitions for: `Maybe' + Imported from Prelude at tcfail068.hs:4 + Defined at tcfail068.hs:68 + +tcfail068.hs:19: Value not in scope: `returnStrictlyST' + +tcfail068.hs:19: Value not in scope: `seqStrictlyST' + +tcfail068.hs:21: Value not in scope: `thenStrictlyST' + +tcfail068.hs:26: Value not in scope: `returnStrictlyST' + +tcfail068.hs:26: Value not in scope: `seqStrictlyST' + +tcfail068.hs:29: Value not in scope: `returnStrictlyST' + +tcfail068.hs:30: Value not in scope: `seqStrictlyST' + +tcfail068.hs:29: Value not in scope: `thenStrictlyST' + +tcfail068.hs:38: Value not in scope: `returnStrictlyST' + +tcfail068.hs:38: Value not in scope: `thenStrictlyST' + +tcfail068.hs:41: Value not in scope: `returnStrictlyST' + +tcfail068.hs:42: Value not in scope: `seqStrictlyST' + +tcfail068.hs:41: Value not in scope: `thenStrictlyST' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail069.hs b/ghc/tests/typecheck/should_fail/tcfail069.hs new file mode 100644 index 0000000000000000000000000000000000000000..73dd738549470d2a7e1daf16161a8bae0ae7e9e1 --- /dev/null +++ b/ghc/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 Too_Kuch( too_much ) 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/ghc/tests/typecheck/should_fail/tcfail069.stderr b/ghc/tests/typecheck/should_fail/tcfail069.stderr new file mode 100644 index 0000000000000000000000000000000000000000..52f3ae9cb8cf5e183235cf02f1092c6b5feb9fed --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail069.stderr @@ -0,0 +1,17 @@ + +tcfail069.hs:21: Couldn't match the type + `PrelBase.[]' against `PrelTup.(,) [PrelBase.Int]' + Expected: `[taCf]' + Inferred: `([PrelBase.Int], [PrelBase.Int])' + In a "case" branch: `PrelBase.[]' -> `IOBase.error "foo"' + In the case expression + `case (list1, (list2)) of PrelBase.[] -> IOBase.error "foo"' + In an equation for function `too_much': + `too_much ds ((k, m) PrelBase.: q1) s0 + = case (list1, (list2)) of PrelBase.[] -> IOBase.error "foo" + where + list2 = ds + list1 = ds' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail070.hs b/ghc/tests/typecheck/should_fail/tcfail070.hs new file mode 100644 index 0000000000000000000000000000000000000000..d6cd3d7eab16b976561a237253f569f6e0d5e28d --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail070.hs @@ -0,0 +1,14 @@ +{- +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 +-} + +type State = ([Int] Bool) + diff --git a/ghc/tests/typecheck/should_fail/tcfail070.stderr b/ghc/tests/typecheck/should_fail/tcfail070.stderr new file mode 100644 index 0000000000000000000000000000000000000000..010e65340aab23d79a2df91f77ed82eb9441e585 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail070.stderr @@ -0,0 +1,7 @@ + +tcfail070.hs:13: Couldn't match the kind `*' against `* -> ka1921' + When unifying two kinds `*' and `* -> ka1921' + In the type declaration for `State' + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail071.hs b/ghc/tests/typecheck/should_fail/tcfail071.hs new file mode 100644 index 0000000000000000000000000000000000000000..49587286b998ba457e3adf94f0a8a7623bde9eab --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail071.hs @@ -0,0 +1,10 @@ +--!!! Mis-matched contexts in a mutually recursive group + +module Foo7( f ) where + +f :: (Ord c) => c -> c +f c = g c + +g :: c -> c +g c = c + where p = foldr (f c) [] [] diff --git a/ghc/tests/typecheck/should_fail/tcfail071.stderr b/ghc/tests/typecheck/should_fail/tcfail071.stderr new file mode 100644 index 0000000000000000000000000000000000000000..c6067c2ba630d57901f28495329939af888cb25b --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail071.stderr @@ -0,0 +1,18 @@ + +tcfail071.hs:10: Couldn't match the signature/existential type variable + `taCF' with the type `taCR -> taCS -> taCS' + Expected: `taCR -> taCS -> taCS' + Inferred: `taCF' + In the first argument of `PrelBase.foldr', namely `(f c)' + In an equation for function `g': + `g c + = c + where + p = PrelBase.foldr (f c) PrelBase.[] PrelBase.[]' + +tcfail071.hs:8: Mismatched contexts + When matching the contexts of the signatures for `f' and `g' + (the signature contexts in a mutually recursive group should all be identical) + + +Compilation had errors diff --git a/ghc/tests/typecheck/should_fail/tcfail072.hs b/ghc/tests/typecheck/should_fail/tcfail072.hs new file mode 100644 index 0000000000000000000000000000000000000000..f7f57a76f4ed50ae2dbc81ebf454216833b2802a --- /dev/null +++ b/ghc/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 Tmp( g ) 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/ghc/tests/typecheck/should_fail/tcfail073.hs b/ghc/tests/typecheck/should_fail/tcfail073.hs new file mode 100644 index 0000000000000000000000000000000000000000..00a06cbecef608f66880ecb52d94b0c2a9d33a57 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail073.hs @@ -0,0 +1,8 @@ +-- what error do you get if you redefined PreludeCore instances? + +module Test where + +f x@(a,b) y@(c,d) = x == y + +instance Eq (a,b) where + (m,n) == (o,p) = m == o diff --git a/ghc/tests/typecheck/should_fail/tcfail074.hs b/ghc/tests/typecheck/should_fail/tcfail074.hs new file mode 100644 index 0000000000000000000000000000000000000000..a59734c8cf2ab6b45f06f759fecf3f11c5a15477 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail074.hs @@ -0,0 +1,8 @@ +{- SHOULD FAIL + + GHC 2.02 failed to realise that this bogus + program didn't have the right type for main +-} + +main = 2 +main = putStrLn "hello world" diff --git a/ghc/tests/typecheck/should_fail/tcfail075.hs b/ghc/tests/typecheck/should_fail/tcfail075.hs new file mode 100644 index 0000000000000000000000000000000000000000..42f7c7572e14a099c93dca3b9fd39813d8759228 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail075.hs @@ -0,0 +1,16 @@ +--!! Test top-level unboxed types + +{-# OPTIONS -fglasgow-exts #-} + +module Main where + +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/ghc/tests/typecheck/should_run/Makefile b/ghc/tests/typecheck/should_run/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d012c9db08ba66e42eef4b65aa3d95f6d797af5f --- /dev/null +++ b/ghc/tests/typecheck/should_run/Makefile @@ -0,0 +1,16 @@ +TOP = ../../../.. +include $(TOP)/mk/boilerplate.mk + +HS_SRCS = $(wildcard *.hs) +BINS = $(patsubst %.o,%,$(HS_OBJS)) + +SRC_RUNTEST_OPTS += -o1 $*.stdout -o2 $*.stderr -x 0 +HC_OPTS += -noC -dcore-lint + +all :: $(BINS) + +%.o : % + $(HC) $(HC_OPTS) $< -o $@ + + +include $(TOP)/mk/target.mk diff --git a/ghc/tests/typecheck/should_run/tcrun001.hs b/ghc/tests/typecheck/should_run/tcrun001.hs new file mode 100644 index 0000000000000000000000000000000000000000..00b4945e036c77121ddf73d0261d5f1814e2422e --- /dev/null +++ b/ghc/tests/typecheck/should_run/tcrun001.hs @@ -0,0 +1,16 @@ +--!! Test for (->) instances + +module Main where + +class Flob k where + twice :: k a a -> k a a + +instance Flob (->) where + twice f = f . f + +inc :: Int -> Int +inc x = x+1 + +main = print (twice inc 2) + +