Skip to content

GHC gives incorrect warnings with simple applications of the view patterns extension

GHC is not able to infer exhaustivity of f1 in the following example

{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
module VP where


f1, f2 :: Either Int Int -> Either Int Int

f1 (id -> Left _ ) = undefined
f1 (id -> Right _ ) = undefined

f2 (Left _ ) = undefined
f2 (Right _ ) = undefined


f (id -> _) = undefined

GHC outputs:

[1 of 1] Compiling VP               ( VP.hs, interpreted )

VP.hs:8:1:
    Warning: Pattern match(es) are non-exhaustive
             In an equation for `f1': Patterns not matched: _
Ok, modules loaded: VP.

I've tested this with GHC 7.0.4, 7.2.2, and 7.4.1-rc1 on Mac OS X.

BTW: There is neither a version entry for 7.2.2 nor for 7.4.1-rc1 in Trac.

Trac metadata
Trac field Value
Version 7.3
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