diff options
Diffstat (limited to 'testsuite/tests/mdo/should_fail')
21 files changed, 152 insertions, 0 deletions
diff --git a/testsuite/tests/mdo/should_fail/Makefile b/testsuite/tests/mdo/should_fail/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/mdo/should_fail/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/mdo/should_fail/all.T b/testsuite/tests/mdo/should_fail/all.T new file mode 100644 index 0000000000..6693587bab --- /dev/null +++ b/testsuite/tests/mdo/should_fail/all.T @@ -0,0 +1,7 @@ +setTestOpts(only_ways(['normal'])); + +test('mdofail001', normal, compile_fail, ['']) +test('mdofail002', normal, compile_fail, ['']) +test('mdofail003', normal, compile_fail, ['']) +test('mdofail004', normal, compile, ['']) +test('mdofail005', normal, compile_fail, ['']) diff --git a/testsuite/tests/mdo/should_fail/mdofail001.hs b/testsuite/tests/mdo/should_fail/mdofail001.hs new file mode 100644 index 0000000000..fe8f95e766 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail001.hs @@ -0,0 +1,16 @@ +{-# OPTIONS -XRecursiveDo #-} + +-- let bindings are monomorphic if used prior to their definition + +module Main (main) where + +import Control.Monad.Fix + +t :: IO (Int, Int) +t = mdo x <- return (l "1", l [1,2,3]) + let l [] = 0 + l (x:xs) = 1 + l xs + return x + +main :: IO () +main = t >>= print diff --git a/testsuite/tests/mdo/should_fail/mdofail001.stderr b/testsuite/tests/mdo/should_fail/mdofail001.stderr new file mode 100644 index 0000000000..8660e167fe --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail001.stderr @@ -0,0 +1,11 @@ + +mdofail001.hs:1:12: + Warning: -XRecursiveDo is deprecated: use -XDoRec or pragma {-# LANGUAGE DoRec #-} instead + +mdofail001.hs:10:36: + No instance for (Num Char) + arising from the literal `3' + Possible fix: add an instance declaration for (Num Char) + In the expression: 3 + In the first argument of `l', namely `[1, 2, 3]' + In the expression: l [1, 2, 3] diff --git a/testsuite/tests/mdo/should_fail/mdofail001.stderr-ghc-7.0 b/testsuite/tests/mdo/should_fail/mdofail001.stderr-ghc-7.0 new file mode 100644 index 0000000000..189c414315 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail001.stderr-ghc-7.0 @@ -0,0 +1,8 @@ + +mdofail001.hs:10:36: + No instance for (Num Char) + arising from the literal `3' + Possible fix: add an instance declaration for (Num Char) + In the expression: 3 + In the first argument of `l', namely `[1, 2, 3]' + In the expression: l [1, 2, 3] diff --git a/testsuite/tests/mdo/should_fail/mdofail001.stderr-hugs b/testsuite/tests/mdo/should_fail/mdofail001.stderr-hugs new file mode 100644 index 0000000000..3bfe41e9f4 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail001.stderr-hugs @@ -0,0 +1 @@ +ERROR "mdofail001.hs":10 - Instance of Num Char required for definition of t diff --git a/testsuite/tests/mdo/should_fail/mdofail002.hs b/testsuite/tests/mdo/should_fail/mdofail002.hs new file mode 100644 index 0000000000..27c9861f38 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail002.hs @@ -0,0 +1,15 @@ +{-# OPTIONS -XRecursiveDo #-} + +-- shadowing is not allowed + +module Main (main) where + +import Control.Monad.Fix + +t :: IO () +t = mdo x <- return 1 + x <- return 2 + return () + +main :: IO () +main = t diff --git a/testsuite/tests/mdo/should_fail/mdofail002.stderr b/testsuite/tests/mdo/should_fail/mdofail002.stderr new file mode 100644 index 0000000000..4da766311e --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail002.stderr @@ -0,0 +1,8 @@ + +mdofail002.hs:1:12: + Warning: -XRecursiveDo is deprecated: use -XDoRec or pragma {-# LANGUAGE DoRec #-} instead + +mdofail002.hs:10:9: + Conflicting definitions for `x' + Bound at: mdofail002.hs:10:9 + mdofail002.hs:11:9 diff --git a/testsuite/tests/mdo/should_fail/mdofail002.stderr-ghc-7.0 b/testsuite/tests/mdo/should_fail/mdofail002.stderr-ghc-7.0 new file mode 100644 index 0000000000..a1327c6dfd --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail002.stderr-ghc-7.0 @@ -0,0 +1,5 @@ + +mdofail002.hs:10:9: + Conflicting definitions for `x' + Bound at: mdofail002.hs:10:9 + mdofail002.hs:11:9 diff --git a/testsuite/tests/mdo/should_fail/mdofail002.stderr-hugs b/testsuite/tests/mdo/should_fail/mdofail002.stderr-hugs new file mode 100644 index 0000000000..4f1c0a0bb4 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail002.stderr-hugs @@ -0,0 +1 @@ +ERROR "mdofail002.hs":10 - Repeated use of variable "x" in pattern binding diff --git a/testsuite/tests/mdo/should_fail/mdofail003.hs b/testsuite/tests/mdo/should_fail/mdofail003.hs new file mode 100644 index 0000000000..ba7e80a74b --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail003.hs @@ -0,0 +1,15 @@ +{-# OPTIONS -XRecursiveDo #-} + +-- shadowing is not allowed II + +module Main (main) where + +import Control.Monad.Fix + +t :: IO () +t = mdo x <- return 1 + let x 0 = 4 + return () + +main :: IO () +main = t diff --git a/testsuite/tests/mdo/should_fail/mdofail003.stderr b/testsuite/tests/mdo/should_fail/mdofail003.stderr new file mode 100644 index 0000000000..fceb7d2b82 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail003.stderr @@ -0,0 +1,8 @@ + +mdofail003.hs:1:12: + Warning: -XRecursiveDo is deprecated: use -XDoRec or pragma {-# LANGUAGE DoRec #-} instead + +mdofail003.hs:10:9: + Conflicting definitions for `x' + Bound at: mdofail003.hs:10:9 + mdofail003.hs:11:13 diff --git a/testsuite/tests/mdo/should_fail/mdofail003.stderr-ghc-7.0 b/testsuite/tests/mdo/should_fail/mdofail003.stderr-ghc-7.0 new file mode 100644 index 0000000000..e093fe0a75 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail003.stderr-ghc-7.0 @@ -0,0 +1,5 @@ + +mdofail003.hs:10:9: + Conflicting definitions for `x' + Bound at: mdofail003.hs:10:9 + mdofail003.hs:11:13 diff --git a/testsuite/tests/mdo/should_fail/mdofail003.stderr-hugs b/testsuite/tests/mdo/should_fail/mdofail003.stderr-hugs new file mode 100644 index 0000000000..ef14fdcff3 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail003.stderr-hugs @@ -0,0 +1 @@ +ERROR "mdofail003.hs":10 - Repeated use of variable "x" in pattern binding diff --git a/testsuite/tests/mdo/should_fail/mdofail004.hs b/testsuite/tests/mdo/should_fail/mdofail004.hs new file mode 100644 index 0000000000..37cd757312 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail004.hs @@ -0,0 +1,22 @@ +{-# OPTIONS -XRecursiveDo #-} + +-- OLD: mdo requires MonadFix instance, even +-- if no recursion is present + +-- Dec 2010: Small change of behaviour +-- MonadFix is only required if recursion is present + +module Main (main) where + +import Control.Monad.Fix + +data X a = X a deriving Show + +instance Monad X where + return = X + (X a) >>= f = f a + +z :: X [Int] +z = mdo { a <- return 1; return [a] } + +main = print z diff --git a/testsuite/tests/mdo/should_fail/mdofail004.stderr b/testsuite/tests/mdo/should_fail/mdofail004.stderr new file mode 100644 index 0000000000..7a96d65197 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail004.stderr @@ -0,0 +1,3 @@ + +mdofail004.hs:1:12: + Warning: -XRecursiveDo is deprecated: use -XDoRec or pragma {-# LANGUAGE DoRec #-} instead diff --git a/testsuite/tests/mdo/should_fail/mdofail004.stderr-ghc-7.0 b/testsuite/tests/mdo/should_fail/mdofail004.stderr-ghc-7.0 new file mode 100644 index 0000000000..63c0cae6ac --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail004.stderr-ghc-7.0 @@ -0,0 +1,7 @@ + +mdofail004.hs:17:5: + No instance for (MonadFix X) + arising from a do statement + Possible fix: add an instance declaration for (MonadFix X) + In the expression: mdo { return [1, 2, ....] } + In an equation for `z': z = mdo { return [1, ....] } diff --git a/testsuite/tests/mdo/should_fail/mdofail004.stderr-hugs b/testsuite/tests/mdo/should_fail/mdofail004.stderr-hugs new file mode 100644 index 0000000000..c787c4209b --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail004.stderr-hugs @@ -0,0 +1 @@ +ERROR "mdofail004.hs":17 - Instance of MonadFix X required for definition of z diff --git a/testsuite/tests/mdo/should_fail/mdofail005.hs b/testsuite/tests/mdo/should_fail/mdofail005.hs new file mode 100644 index 0000000000..b4d52918a5 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail005.hs @@ -0,0 +1,12 @@ + + +-- use of mdo requires an extension, +-- so let's try not enabling it + +module Main (main) where + +import Control.Monad.Fix + +main :: IO () +main = mdo x <- return (1:x) + return () diff --git a/testsuite/tests/mdo/should_fail/mdofail005.stderr b/testsuite/tests/mdo/should_fail/mdofail005.stderr new file mode 100644 index 0000000000..306df25706 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail005.stderr @@ -0,0 +1,2 @@ + +mdofail005.hs:11:14: parse error on input `<-' diff --git a/testsuite/tests/mdo/should_fail/mdofail005.stderr-hugs b/testsuite/tests/mdo/should_fail/mdofail005.stderr-hugs new file mode 100644 index 0000000000..6bb11378a1 --- /dev/null +++ b/testsuite/tests/mdo/should_fail/mdofail005.stderr-hugs @@ -0,0 +1 @@ +ERROR "mdofail005.hs":11 - Syntax error in input (unexpected `<-') |