Commit fdf11c90 authored by Shayne Fletcher's avatar Shayne Fletcher 🥝 Committed by Ben Gamari

rebindable-clash-warning-fix : correct warning logic

parent 07022297
......@@ -944,7 +944,7 @@ tcMonadFailOp orig pat fail_op res_ty
rebindableSyntax <- xoptM LangExt.RebindableSyntax
; desugarFlag <- xoptM LangExt.MonadFailDesugaring
; missingWarning <- woptM Opt_WarnMissingMonadFailInstances
; if | rebindableSyntax && (desugarFlag || missingWarning)
; if | rebindableSyntax && desugarFlag && missingWarning
-> warnRebindableClash pat
| not desugarFlag && missingWarning
-> emitMonadFailConstraint pat res_ty
......
......@@ -21,6 +21,10 @@ test('rebindable8', normal, compile, [''])
test('rebindable9', normal, compile, [''])
test('rebindable10', normal, compile_and_run, [''])
# Test rebindable clash warnings
test('rebindable11', normal, compile, [''])
test('rebindable12', normal, compile_fail, [''])
test('T303', normal, compile, [''])
# Tests from Oleg
......
{-# LANGUAGE RebindableSyntax, MonadFailDesugaring #-}
{-# OPTIONS_GHC -Wno-missing-monadfail-instances #-}
-- Test that rebindable clash warnings are not displayed. This program
-- should not generate anything on stderr at compile time.
module Main where
import Prelude
catMaybes xs = do
Just x <- xs
return x
main = return ()
{-# LANGUAGE RebindableSyntax, MonadFailDesugaring #-}
{-# OPTIONS_GHC -Wmissing-monadfail-instances #-}
-- Test that rebindable clash warnings are displayed.
module Main where
import Prelude
catMaybes xs = do
Just x <- xs
return x
main = return ()
rebindable12.hs:11:5: error: [-Wmissing-monadfail-instances (in -Wcompat), -Werror=missing-monadfail-instances]
The failable pattern ‘Just x’
is used together with -XRebindableSyntax. If this is intentional,
compile with -Wno-missing-monadfail-instances.
Markdown is supported
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