GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:14:41Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/15014Exhaustivity check should suggest when COMPLETE could be helpful2019-07-07T18:14:41ZEdward Z. YangExhaustivity check should suggest when COMPLETE could be helpful```
MacBook-Pro-97:ghc ezyang$ cat A.hs
{-# LANGUAGE PatternSynonyms #-}
module A where
pattern F :: a -> b -> (a, b)
pattern F x y = (x, y)
g :: (a, b) -> (a, b)
g (F x y) = (x, y)
MacBook-Pro-97:ghc ezyang$ inplace/bin/ghc-stage2 -c ...```
MacBook-Pro-97:ghc ezyang$ cat A.hs
{-# LANGUAGE PatternSynonyms #-}
module A where
pattern F :: a -> b -> (a, b)
pattern F x y = (x, y)
g :: (a, b) -> (a, b)
g (F x y) = (x, y)
MacBook-Pro-97:ghc ezyang$ inplace/bin/ghc-stage2 -c A.hs -Wall -fforce-recomp
A.hs:8:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for āgā: Patterns not matched: _
|
8 | g (F x y) = (x, y)
| ^^^^^^^^^^^^^^^^^^
MacBook-Pro-97:ghc ezyang$ inplace/bin/ghc-stage2 --version
The Glorious Glasgow Haskell Compilation System, version 8.5.20180304
```
Any time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Exhaustivity check should suggest when COMPLETE could be helpful","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.4.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["PatternMatchWarnings","PatternSynonyms,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\nMacBook-Pro-97:ghc ezyang$ cat A.hs\r\n{-# LANGUAGE PatternSynonyms #-}\r\nmodule A where\r\n\r\npattern F :: a -> b -> (a, b)\r\npattern F x y = (x, y)\r\n\r\ng :: (a, b) -> (a, b)\r\ng (F x y) = (x, y)\r\nMacBook-Pro-97:ghc ezyang$ inplace/bin/ghc-stage2 -c A.hs -Wall -fforce-recomp\r\n\r\nA.hs:8:1: warning: [-Wincomplete-patterns]\r\n Pattern match(es) are non-exhaustive\r\n In an equation for āgā: Patterns not matched: _\r\n |\r\n8 | g (F x y) = (x, y)\r\n | ^^^^^^^^^^^^^^^^^^\r\nMacBook-Pro-97:ghc ezyang$ inplace/bin/ghc-stage2 --version\r\nThe Glorious Glasgow Haskell Compilation System, version 8.5.20180304\r\n}}}\r\n\r\nAny time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.3