summaryrefslogtreecommitdiff
path: root/testsuite/tests/pmcheck
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2020-08-12 18:35:28 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-10 10:35:33 -0400
commit67ce72da1689058cb689ffbb6fcbd5cd12af56df (patch)
tree694ee73ed29fc5953b1cc2f57c72f0761c8ad5dc /testsuite/tests/pmcheck
parent4798caa0fefd7adf4c5b85fa84a6f28fcc6b350b (diff)
downloadhaskell-67ce72da1689058cb689ffbb6fcbd5cd12af56df.tar.gz
Add long-distance info for pattern bindings (#18572)
We didn't consider the RHS of a pattern-binding before, which led to surprising warnings listed in #18572. As can be seen from the regression test T18572, we get the expected output now.
Diffstat (limited to 'testsuite/tests/pmcheck')
-rw-r--r--testsuite/tests/pmcheck/should_compile/T18572.hs12
-rw-r--r--testsuite/tests/pmcheck/should_compile/T18572.stderr16
-rw-r--r--testsuite/tests/pmcheck/should_compile/all.T6
3 files changed, 32 insertions, 2 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T18572.hs b/testsuite/tests/pmcheck/should_compile/T18572.hs
new file mode 100644
index 0000000000..9a37de4813
--- /dev/null
+++ b/testsuite/tests/pmcheck/should_compile/T18572.hs
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -Wincomplete-uni-patterns -Wincomplete-patterns -fforce-recomp #-}
+{-# LANGUAGE DataKinds, KindSignatures, GADTs #-}
+
+module T18572 where
+
+True = True
+
+data SBool (b :: Bool) where
+ STrue :: SBool True
+ SFalse :: SBool False
+
+STrue = SFalse
diff --git a/testsuite/tests/pmcheck/should_compile/T18572.stderr b/testsuite/tests/pmcheck/should_compile/T18572.stderr
new file mode 100644
index 0000000000..15d9f7c5b5
--- /dev/null
+++ b/testsuite/tests/pmcheck/should_compile/T18572.stderr
@@ -0,0 +1,16 @@
+
+T18572.hs:12:1: warning: [-Winaccessible-code (in -Wdefault)]
+ • Couldn't match type ‘'False’ with ‘'True’
+ Inaccessible code in
+ a pattern with constructor: STrue :: SBool 'True,
+ in a pattern binding
+ • In the pattern: STrue
+ In a pattern binding: STrue = SFalse
+
+T18572.hs:12:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match is redundant
+ In a pattern binding: STrue = ...
+
+T18572.hs:12:1: warning: [-Wincomplete-uni-patterns]
+ Pattern match(es) are non-exhaustive
+ In a pattern binding: Patterns not matched: SFalse
diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T
index 51fb76b078..ee69cf176a 100644
--- a/testsuite/tests/pmcheck/should_compile/all.T
+++ b/testsuite/tests/pmcheck/should_compile/all.T
@@ -102,6 +102,8 @@ test('T17234', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T17248', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
+test('T17340', normal, compile,
+ ['-Wredundant-bang-patterns'])
test('T17357', expect_broken(17357), compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T17376', normal, compile,
@@ -124,8 +126,8 @@ test('T18478', collect_compiler_stats('bytes allocated',10), compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T18533', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
-test('T17340', normal, compile,
- ['-Wredundant-bang-patterns'])
+test('T18572', normal, compile,
+ ['-fwarn-incomplete-patterns -fwarn-incomplete-uni-patterns -fwarn-overlapping-patterns'])
# Other tests
test('pmc001', [], compile,