Skip to content

Spurious warning about incomplete pattern with PatternSynonyms

{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE PatternSynonyms #-}

module Test where

f :: Int -> Bool
f (id -> a) = True

pattern X a <- (id -> a)

g :: Int -> Bool
g (X a) = True

When compiling with -Wincomplete-patterns, this code produces an (incorrect) warning for g, but not for f. The only difference is that g uses a pattern synonym.

K.hs:12:1: warning: [-Wincomplete-patterns]
    Pattern match(es) are non-exhaustive
    In an equation for ‘g’: Patterns not matched: _
   |
12 | g (X a) = True
   | ^^^^^^^^^^^^^^
Trac metadata
Trac field Value
Version 8.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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