[commit: ghc] master: rebindable-clash-warning-fix : correct warning logic (fdf11c9)

git at git.haskell.org git at git.haskell.org
Sat Dec 29 00:14:09 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/fdf11c90992762f6f6264b8d8c1678c4ddd53eb8/ghc

>---------------------------------------------------------------

commit fdf11c90992762f6f6264b8d8c1678c4ddd53eb8
Author: Shayne Fletcher <shayne.fletcher at digitalasset.com>
Date:   Fri Dec 28 19:13:51 2018 -0500

    rebindable-clash-warning-fix : correct warning logic


>---------------------------------------------------------------

fdf11c90992762f6f6264b8d8c1678c4ddd53eb8
 compiler/typecheck/TcMatches.hs                           |  2 +-
 testsuite/tests/rebindable/all.T                          |  4 ++++
 testsuite/tests/rebindable/rebindable11.hs                | 15 +++++++++++++++
 .../tests/rebindable/rebindable11.stderr                  |  0
 testsuite/tests/rebindable/rebindable12.hs                | 14 ++++++++++++++
 .../rebindable12.stderr}                                  |  3 +--
 6 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/compiler/typecheck/TcMatches.hs b/compiler/typecheck/TcMatches.hs
index 4ddf862..6bc988a 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 f796a38..1484dd7 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 0000000..13e1b2d
--- /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/libraries/ghc-compact/tests/compact_serialize.stderr b/testsuite/tests/rebindable/rebindable11.stderr
similarity index 100%
copy from libraries/ghc-compact/tests/compact_serialize.stderr
copy to testsuite/tests/rebindable/rebindable11.stderr
diff --git a/testsuite/tests/rebindable/rebindable12.hs b/testsuite/tests/rebindable/rebindable12.hs
new file mode 100644
index 0000000..fd2e1c7
--- /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/monadfail/MonadFailWarningsWithRebindableSyntax.stderr b/testsuite/tests/rebindable/rebindable12.stderr
similarity index 59%
copy from testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr
copy to testsuite/tests/rebindable/rebindable12.stderr
index 7b6cd1b..722a95c 100644
--- a/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr
+++ b/testsuite/tests/rebindable/rebindable12.stderr
@@ -1,5 +1,4 @@
-
-MonadFailWarningsWithRebindableSyntax.hs:13:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
+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.



More information about the ghc-commits mailing list