diff options
-rw-r--r-- | compiler/typecheck/TcMatches.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/rebindable/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable11.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable11.stderr | 0 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable12.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable12.stderr | 4 |
6 files changed, 38 insertions, 1 deletions
diff --git a/compiler/typecheck/TcMatches.hs b/compiler/typecheck/TcMatches.hs index 4ddf862bf7..6bc988a8f5 100644 --- a/compiler/typecheck/TcMatches.hs +++ b/compiler/typecheck/TcMatches.hs @@ -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 diff --git a/testsuite/tests/rebindable/all.T b/testsuite/tests/rebindable/all.T index f796a38750..1484dd73d9 100644 --- a/testsuite/tests/rebindable/all.T +++ b/testsuite/tests/rebindable/all.T @@ -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 diff --git a/testsuite/tests/rebindable/rebindable11.hs b/testsuite/tests/rebindable/rebindable11.hs new file mode 100644 index 0000000000..13e1b2dd3d --- /dev/null +++ b/testsuite/tests/rebindable/rebindable11.hs @@ -0,0 +1,15 @@ +{-# 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 () diff --git a/testsuite/tests/rebindable/rebindable11.stderr b/testsuite/tests/rebindable/rebindable11.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/rebindable/rebindable11.stderr diff --git a/testsuite/tests/rebindable/rebindable12.hs b/testsuite/tests/rebindable/rebindable12.hs new file mode 100644 index 0000000000..fd2e1c7bb3 --- /dev/null +++ b/testsuite/tests/rebindable/rebindable12.hs @@ -0,0 +1,14 @@ +{-# 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 () diff --git a/testsuite/tests/rebindable/rebindable12.stderr b/testsuite/tests/rebindable/rebindable12.stderr new file mode 100644 index 0000000000..722a95c293 --- /dev/null +++ b/testsuite/tests/rebindable/rebindable12.stderr @@ -0,0 +1,4 @@ +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. |