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
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:
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.
Fixes #20642 (closed).
I also cleaned up the all.T file of the testsuite in a separate commit.