-Wcomplete-uni-pattern: GHC 8.10 regression in error message
Summary
Since 8.10, error message listing missing patterns contains unnecessary case splits.
Steps to reproduce
{-# OPTIONS_GHC -Wincomplete-uni-patterns #-}
foo :: [a] -> [a]
foo [] = []
foo xs = ys
where
(_, ys@(_:_)) = splitAt 0 xs
main :: IO ()
main = putStrLn $ foo $ "Hello, coverage checker!"
Expected behavior
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: (_, [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Actual behavior
$ for ver in 8.4.4 8.6.5 8.8.4 8.10.7 9.0.1 9.2.1; do ghc-$ver -fno-code ListPair.hs; done
This demonstrates that the regression happened from 8.6 to 8.8. (Good error: 8.4.4 8.6.5 8.8.4. Bad error: 8.10.7 9.0.1 9.2.1.)
[1 of 1] Compiling Main ( ListPair.hs, nothing )
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: (_, [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1 of 1] Compiling Main ( ListPair.hs, nothing )
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: (_, [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1 of 1] Compiling Main ( ListPair.hs, nothing )
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: (_, [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1 of 1] Compiling Main ( ListPair.hs, nothing )
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns not matched:
([], [])
((_:_), [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Loaded package environment from /Users/abel/.ghc/x86_64-darwin-9.0.1/environments/default
[1 of 1] Compiling Main ( ListPair.hs, nothing )
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns not matched:
([], [])
((_:_), [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1 of 1] Compiling Main ( ListPair.hs, nothing )
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:
([], [])
((_:_), [])
|
7 | (_, ys@(_:_)) = splitAt 0 xs
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^