Commit d09b00a8 authored by batterseapower's avatar batterseapower
Browse files

Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263

parent ebd17366
-- Trac #3263. New kind of warning on ignored monadic bindings
module T3263 where
nullM :: IO ()
nullM = return ()
nonNullM :: IO Int
nonNullM = return 10
-- No warning
t1 = do
nonNullM
-- No warning
t2 = nonNullM
-- No warning
t3 = do
nullM
nonNullM
-- Warning
t4 = do
nonNullM
nullM
-- No warning
t5 = do
_ <- nonNullM
nullM
-- Warning
t6 = mdo
nonNullM
nullM
\ No newline at end of file
T3263-1.hs:25:2:
Warning: A do-notation statement threw away a result of a type which appears to contain something other than (), namely Int. You can suppress this warning by explicitly binding the result to _
T3263-1.hs:35:2:
Warning: A do-notation statement threw away a result of a type which appears to contain something other than (), namely Int. You can suppress this warning by explicitly binding the result to _
-- Trac #3263. New kind of warning on monadic bindings that discard a monadic result
module T3263 where
import Control.Monad.Fix
-- No warning
t1 :: Monad m => m Int
t1 = do
return 10
-- No warning
t2 :: Monad m => m (m Int)
t2 = return (return 10)
-- No warning
t3 :: Monad m => m (m Int)
t3 = do
return 10
return (return 10)
-- Warning
t4 :: forall m. Monad m => m Int
t4 = do
return (return 10 :: m Int)
return 10
-- No warning
t5 :: forall m. Monad m => m Int
t5 = do
_ <- return (return 10 :: m Int)
return 10
-- Warning
t6 :: forall m. MonadFix m => m Int
t6 = mdo
return (return 10 :: m Int)
return 10
\ No newline at end of file
T3263-2.hs:25:2:
Warning: A do-notation statement threw away a result of a type that like a monadic action waiting to execute, namely m Int. You can suppress this warning by explicitly binding the result to _
T3263-2.hs:37:2:
Warning: A do-notation statement threw away a result of a type that like a monadic action waiting to execute, namely m Int. You can suppress this warning by explicitly binding the result to _
......@@ -66,4 +66,7 @@ test('ds059', normal, compile, ['-W'])
test('ds060', expect_broken(322), compile, [''])
test('ds061', expect_broken(851), compile, [''])
test('ds062', normal, compile, [''])
test('T2409', normal, compile, [''])
test('T3263-1', if_compiler_lt('ghc', '6.11', expect_fail), compile, ['-fwarn-unused-do-bind -XRecursiveDo'])
test('T3263-2', if_compiler_lt('ghc', '6.11', expect_fail), compile, ['-fwarn-wrong-do-bind -XScopedTypeVariables -XRecursiveDo'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment