summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorHE, Tao <sighingnow@gmail.com>2018-03-02 14:16:24 -0500
committerBen Gamari <ben@smart-cactus.org>2018-03-02 14:52:10 -0500
commite8e9f6a7a6d857efe6e3b2aec0c4964f9a8fa09a (patch)
tree2ce712a6b9c00bf2d1e969bbb1db28a8858a14c7 /testsuite/tests
parent8c7a1551fcd004c37f4ccd99c7c10395179519f1 (diff)
downloadhaskell-e8e9f6a7a6d857efe6e3b2aec0c4964f9a8fa09a.tar.gz
Improve exhaustive checking for guards in pattern bindings and MultiIf.
Previously we didn't do exhaustive checking on MultiIf expressions and guards in pattern bindings. We can construct the `LMatch` directly from GRHSs or [LHsExpr] (MultiIf's alts) then feed it to checkMatches, without construct the MatchGroup and using function `matchWrapper`. Signed-off-by: HE, Tao <sighingnow@gmail.com> Test Plan: make test TEST="T14773a T14773b" Reviewers: bgamari, RyanGlScott, simonpj Reviewed By: bgamari, simonpj Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14773 Differential Revision: https://phabricator.haskell.org/D4400
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/deSugar/should_compile/T14773a.hs10
-rw-r--r--testsuite/tests/deSugar/should_compile/T14773a.stderr5
-rw-r--r--testsuite/tests/deSugar/should_compile/T14773b.hs8
-rw-r--r--testsuite/tests/deSugar/should_compile/T14773b.stderr5
-rw-r--r--testsuite/tests/deSugar/should_compile/all.T2
5 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_compile/T14773a.hs b/testsuite/tests/deSugar/should_compile/T14773a.hs
new file mode 100644
index 0000000000..6d1e9fca5d
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/T14773a.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE MultiWayIf #-}
+
+module T14773a where
+
+foo :: Bool -> Int
+foo b = if | b -> 1
+
+bar :: Bool -> Int
+bar b = if | b -> 1
+ | otherwise -> 2
diff --git a/testsuite/tests/deSugar/should_compile/T14773a.stderr b/testsuite/tests/deSugar/should_compile/T14773a.stderr
new file mode 100644
index 0000000000..49d1ef05fc
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/T14773a.stderr
@@ -0,0 +1,5 @@
+
+T14773a.hs:6:12: warning: [-Wincomplete-patterns (in -Wextra)]
+ Pattern match(es) are non-exhaustive
+ In a multi-way if alternative:
+ Guards do not cover entire pattern space
diff --git a/testsuite/tests/deSugar/should_compile/T14773b.hs b/testsuite/tests/deSugar/should_compile/T14773b.hs
new file mode 100644
index 0000000000..d11bbfe5d5
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/T14773b.hs
@@ -0,0 +1,8 @@
+module T14773b where
+
+b :: Bool
+(Just b) | False = Nothing
+
+c :: Bool
+(Just c) | False = Nothing
+ | True = Just True
diff --git a/testsuite/tests/deSugar/should_compile/T14773b.stderr b/testsuite/tests/deSugar/should_compile/T14773b.stderr
new file mode 100644
index 0000000000..557b10b8f0
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/T14773b.stderr
@@ -0,0 +1,5 @@
+
+T14773b.hs:4:10: warning: [-Wincomplete-patterns (in -Wextra)]
+ Pattern match(es) are non-exhaustive
+ In a pattern binding guards:
+ Guards do not cover entire pattern space
diff --git a/testsuite/tests/deSugar/should_compile/all.T b/testsuite/tests/deSugar/should_compile/all.T
index fe6535ea3f..2608b7d245 100644
--- a/testsuite/tests/deSugar/should_compile/all.T
+++ b/testsuite/tests/deSugar/should_compile/all.T
@@ -100,3 +100,5 @@ test('T13290', normal, compile, [''])
test('T13257', normal, compile, [''])
test('T13870', normal, compile, [''])
test('T14135', normal, compile, [''])
+test('T14773a', normal, compile, ['-Wincomplete-patterns'])
+test('T14773b', normal, compile, ['-Wincomplete-patterns'])