Opened 6 years ago

Last modified 3 years ago

#5340 new bug

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

Reported by: Lemming Owned by:
Priority: lowest Milestone:
Component: Compiler (Type checker) Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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:

    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.

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.

Change History (2)

comment:1 Changed 6 years ago by simonpj

Milestone: _|_
Priority: normallowest

Well this is very delicate. Yes, since

  • The data type is empty
  • The LeftStrict constructor is strict

I agree that a pattern (LeftStrict a) can never match

But does this come up often enough to be worth special-casing in the compiler.

I'll mark it priority lowest, but if it becomes importand for someone, do yell.

comment:2 Changed 3 years ago by thomie

Component: CompilerCompiler (Type checker)
difficulty: Unknown
Type of failure: None/UnknownIncorrect warning at compile-time
Note: See TracTickets for help on using tickets.