Skip to content

wrong warning on incomplete case analysis in conjunction with empty data declarations

I load the following code into GHCi with warnings enabled (-Wall)

{-# LANGUAGE EmptyDataDecls #-}

data Empty

data EitherStrict a b = LeftStrict !a | RightStrict !b

test :: Char
test =
   case undefined :: EitherStrict Empty Char of
--      LeftStrict _ -> undefined
      RightStrict b -> b

I get the warning:

CaseOfEmptyData.hs:9:3:
    Warning: Pattern match(es) are non-exhaustive
             In a case alternative: Patterns not matched: LeftStrict _

I think this warning is wrong, since the LeftStrict case cannot happen. Am I right?

This may be related to #2431 (closed).

This problem is of minor priority for me. I found that in the original problem EmptyDataDecls would not helped me at all, and I found a better solution in this particular case.

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