summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayne Fletcher <shayne.fletcher@digitalasset.com>2018-12-28 19:13:51 -0500
committerBen Gamari <ben@well-typed.com>2018-12-28 19:13:51 -0500
commitfdf11c90992762f6f6264b8d8c1678c4ddd53eb8 (patch)
tree7be9972b1b348f52390f86dddeb7f71098525ccc
parent07022297749b8091af58a3302581ad90e9ca329b (diff)
downloadhaskell-fdf11c90992762f6f6264b8d8c1678c4ddd53eb8.tar.gz
rebindable-clash-warning-fix : correct warning logic
-rw-r--r--compiler/typecheck/TcMatches.hs2
-rw-r--r--testsuite/tests/rebindable/all.T4
-rw-r--r--testsuite/tests/rebindable/rebindable11.hs15
-rw-r--r--testsuite/tests/rebindable/rebindable11.stderr0
-rw-r--r--testsuite/tests/rebindable/rebindable12.hs14
-rw-r--r--testsuite/tests/rebindable/rebindable12.stderr4
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.