Opened 3 years ago

Closed 2 months ago

Last modified 3 weeks ago

#7669 closed bug (duplicate)

Empty case causes warning

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


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

comment:1 Changed 3 years ago by simonpj@…

commit 9162d159a62d19d4b371b7348eb1b524001fddcd

Author: Simon Peyton Jones <[email protected]>
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 3 years 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!


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


comment:5 Changed 2 years ago by igloo

  • Milestone set to 7.8.1

comment:6 Changed 17 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:7 Changed 10 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:8 Changed 2 months ago by thomie

  • Resolution set to duplicate
  • Status changed from new to closed

Because the existence of duplicate tickets makes doing a BugSweep of the bug tracker more cumbersome, I'm closing these tickets as duplicate. Don't worry, they're still listed on PatternMatchCheck, and will hopefully all be addressed by the work on #595 ("Overhaul GHC's overlapping/non-exhaustive pattern checking").

comment:9 Changed 2 months ago by bgamari

The issue of no warnings being produced despite non-exhaustive pattern matches (described in comment:3) has been reported separately as #10746.

comment:10 Changed 3 weeks ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.