rebindable-clash-warning-fix : correct warning logic
authorShayne Fletcher <shayne.fletcher@digitalasset.com>
Sat, 29 Dec 2018 00:13:51 +0000 (19:13 -0500)
committerBen Gamari <ben@well-typed.com>
Sat, 29 Dec 2018 00:13:51 +0000 (19:13 -0500)
compiler/typecheck/TcMatches.hs
testsuite/tests/rebindable/all.T
testsuite/tests/rebindable/rebindable11.hs [new file with mode: 0644]
testsuite/tests/rebindable/rebindable11.stderr [new file with mode: 0644]
testsuite/tests/rebindable/rebindable12.hs [new file with mode: 0644]
testsuite/tests/rebindable/rebindable12.stderr [new file with mode: 0644]

index 4ddf862..6bc988a 100644 (file)
@@ -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
index f796a38..1484dd7 100644 (file)
@@ -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 (file)
index 0000000..13e1b2d
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/testsuite/tests/rebindable/rebindable12.hs b/testsuite/tests/rebindable/rebindable12.hs
new file mode 100644 (file)
index 0000000..fd2e1c7
--- /dev/null
@@ -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 (file)
index 0000000..722a95c
--- /dev/null
@@ -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.