Skip to content

Incomplete pattern warning with COMPLETE pragma and -fno-code

Summary

When using -fno-code, I get incomplete pattern warnings for matches that have been declared to be complete with the complete pragma. This happens if the pattern match is not done in the module that defines the pattern.

Steps to reproduce

{-# language PatternSynonyms #-}
module Unit where

pattern Unit = ()

{-# complete Unit #-}

f Unit = () -- No warnings
module Other where

import Unit

f Unit = () -- Non-exhaustive patterns warning with -fno-code

Running ghci Other -fwarn-incomplete-patterns produces no warnings, but if I use -fno-code, I get:

% ghci Other -fwarn-incomplete-patterns -fno-code
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/olle/dotfiles/ghc/.ghci
[1 of 2] Compiling Unit             ( Unit.hs, nothing )
[2 of 2] Compiling Other            ( Other.hs, nothing )

Other.hs:5:1: warning: [-Wincomplete-patterns]
    Pattern match(es) are non-exhaustive
    In an equation for ‘f’: Patterns not matched: _
  |
5 | f Unit = () -- Non-exhaustive patterns warning with -fno-code
  | ^^^^^^^^^^^
Ok, two modules loaded.
λ>

Expected behavior

No warnings, like when not using -fno-code.

Environment

  • GHC version used: 8.6.5
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information