Opened 4 years ago

Last modified 3 months 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 Revisions:

Description

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.

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 4 years ago by simonpj

  • Milestone set to _|_
  • Priority changed from normal to lowest

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 months ago by thomie

  • Component changed from Compiler to Compiler (Type checker)
  • difficulty set to Unknown
  • Type of failure changed from None/Unknown to Incorrect warning at compile-time
Note: See TracTickets for help on using tickets.