Case split uncovered patterns in warnings or not?
Sebastian Graf
sgraf1337 at gmail.com
Tue Nov 9 13:17:47 UTC 2021
Hi Devs,
In https://gitlab.haskell.org/ghc/ghc/-/issues/20642 we saw that GHC >=
8.10 outputs pattern match warnings a little differently than it used to.
Example from there:
{-# OPTIONS_GHC -Wincomplete-uni-patterns #-}foo :: [a] -> [a]foo [] =
[]foo xs = ys where (_, ys@(_:_)) = splitAt 0 xsmain :: IO ()main =
putStrLn $ foo $ "Hello, coverage checker!"
Instead of saying
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns] Pattern
match(es) are non-exhaustive In a pattern binding: Patterns not
matched: (_, [])
We now say
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns] Pattern
match(es) are non-exhaustive In a pattern binding: Patterns
of type ‘([a], [a])’ not matched: ([], [])
((_:_), [])
E.g., newer versions do (one) case split on pattern variables that haven't
even been scrutinised by the pattern match. That amounts to quantitatively
more pattern suggestions and for each variable a list of constructors that
could be matched on.
The motivation for the change is outlined in
https://gitlab.haskell.org/ghc/ghc/-/issues/20642#note_390110, but I could
easily be swayed not to do the case split. Which arguably is less
surprising, as Andreas Abel points out.
Considering the other examples from my post, which would you prefer?
Cheers,
Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20211109/bd8e3190/attachment.html>
More information about the ghc-devs
mailing list