Opened 14 months ago

Last modified 12 months ago

#7669 new bug

Empty case causes warning

Reported by: goldfire Owned by:
Priority: normal Milestone: 7.8.3
Component: Compiler Version: 7.7
Keywords: EmptyCase Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Difficulty: Unknown
Test Case: deSugar/should_compile/T7669 Blocked By:
Blocking: Related Tickets:

Description

The following code

{-# LANGUAGE EmptyCase #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
data Void

foo :: Void -> ()
foo x = case x of {}

causes this warning

/Users/rae/temp/Scratch.hs:6:9: Warning:
    Pattern match(es) are non-exhaustive
    In a case alternative: Patterns not matched:
Ok, modules loaded: Main.

Change History (5)

comment:1 Changed 14 months ago by simonpj@…

commit 9162d159a62d19d4b371b7348eb1b524001fddcd

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Wed Feb 13 17:37:17 2013 +0000

    Simplify the base case for 'check', and thereby fix Trac #7669

 compiler/deSugar/Check.lhs |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

comment:2 Changed 14 months ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to deSugar/should_compile/T7669

Thanks. Turns out I could cure this and make the code simpler!

Simon

comment:3 Changed 14 months ago by monoidal

However, previously empty case always gave a warning; now it never does.

f :: Bool -> a
f x = case x of { }

comment:4 Changed 14 months ago by simonpj

  • Resolution fixed deleted
  • Status changed from closed to new

Very true.

Would anyone like to look at the overlapping-pattern warnings? It's a well-defined problem, restricted to a single module in GHC (deSugar/Check.lhs). We have a bunch of tickets about it: at least #595, #5728, #3927, #5724, #5762, #4139, #6124.

A lovely project awaits!

Meanwhile I think I'll leave the code in its simplified state.

Simon

comment:5 Changed 12 months ago by igloo

  • Milestone set to 7.8.1
Note: See TracTickets for help on using tickets.