Opened 18 months ago

#15014 new bug

Exhaustivity check should suggest when COMPLETE could be helpful

Reported by: ezyang Owned by:
Priority: normal Milestone: 8.4.3
Component: Compiler (Type checker) Version: 8.5
Keywords: PatternSynonyms, PatternMatchWarnings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Poor/confusing error message Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

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.

Change History (0)

Note: See TracTickets for help on using tickets.