Opened 3 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 Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

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 (1)

comment:1 Changed 3 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.

Note: See TracTickets for help on using tickets.