Skip to content

Exhaustivity 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 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.

Trac metadata
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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information