summaryrefslogtreecommitdiff
path: root/testsuite/tests/th
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-11-10 12:54:59 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-17 05:11:38 -0500
commit29086749b8d6bec162414fbec8921df0382d0627 (patch)
treeb21134cf637ad64032dc41f3578dc1ba3c783086 /testsuite/tests/th
parent4cec6cf284d65449bbdaf015fadd7768770ec52b (diff)
downloadhaskell-29086749b8d6bec162414fbec8921df0382d0627.tar.gz
Pmc: Don't case split on wildcard matches (#20642)
Since 8.10, when formatting a pattern match warning, we'd case split on a wildcard match such as ```hs foo :: [a] -> [a] foo [] = [] foo xs = ys where (_, ys@(_:_)) = splitAt 0 xs -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- ([], []) -- ((_:_), []) ``` But that's quite verbose and distracts from which part of the pattern was actually the inexhaustive one. We'd prefer a wildcard for the first pair component here, like it used to be in GHC 8.8. On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the different constructors we could've matched on: ```hs f :: Bool -> () f x = case x of {} -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- False -- True ``` The solution is to communicate that we want a top-level case split to `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what this patch arranges. Details in `Note [Case split inhabiting patterns]`. Fixes #20642.
Diffstat (limited to 'testsuite/tests/th')
-rw-r--r--testsuite/tests/th/T19709c.stderr4
-rw-r--r--testsuite/tests/th/T19709d.stderr4
2 files changed, 4 insertions, 4 deletions
diff --git a/testsuite/tests/th/T19709c.stderr b/testsuite/tests/th/T19709c.stderr
index 3bedc08dc9..37451d2023 100644
--- a/testsuite/tests/th/T19709c.stderr
+++ b/testsuite/tests/th/T19709c.stderr
@@ -4,7 +4,7 @@ T19709c.hs:9:7: error: [-Wincomplete-patterns (in -Wextra), -Werror=incomplete-p
In a case alternative:
Patterns of type ‘String’ not matched:
[]
- [p] where p is not one of {'h'}
- (p:_:_) where p is not one of {'h'}
+ (p:_) where p is not one of {'h'}
['h']
+ ('h':p:_) where p is not one of {'e'}
...
diff --git a/testsuite/tests/th/T19709d.stderr b/testsuite/tests/th/T19709d.stderr
index 3ee2ac8424..cacf6acb48 100644
--- a/testsuite/tests/th/T19709d.stderr
+++ b/testsuite/tests/th/T19709d.stderr
@@ -4,9 +4,9 @@ T19709d.hs:6:2: warning: [-Wincomplete-patterns (in -Wextra)]
In a case alternative:
Patterns of type ‘String’ not matched:
[]
- [p] where p is not one of {'h'}
- (p:_:_) where p is not one of {'h'}
+ (p:_) where p is not one of {'h'}
['h']
+ ('h':p:_) where p is not one of {'e'}
...
T19709d.hs:1:1: error: