[GHC] #15450: Inconsistency w.r.t. coverage checking warnings for EmptyCase under unsatisfiable constraints

GHC ghc-devs at haskell.org
Sat Jul 28 15:11:30 UTC 2018


#15450: Inconsistency w.r.t. coverage checking warnings for EmptyCase under
unsatisfiable constraints
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.3
           Keywords:                 |  Operating System:  Unknown/Multiple
  PatternMatchWarnings               |
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #12957
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following code:

 {{{#!hs
 {-# LANGUAGE EmptyCase #-}
 {-# LANGUAGE GADTs #-}
 {-# OPTIONS_GHC -Wincomplete-patterns #-}
 module Bug where

 f :: (Int ~ Bool) => Bool -> a
 f x = case x of {}

 g :: (Int ~ Bool) => Bool -> a
 g x = case x of True -> undefined
 }}}
 {{{
 $ /opt/ghc/8.4.3/bin/ghci Bug.hs
 GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:10:7: warning: [-Wincomplete-patterns]
     Pattern match(es) are non-exhaustive
     In a case alternative: Patterns not matched: False
    |
 10 | g x = case x of True -> undefined
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 }}}

 Observe that we get a non-exhaustivity warning for the `case` expression
 in `g` (thanks to commit adb565aa74582969bbcc3b411d6d518b1c76c3cf), but
 not for the one in `f`. The difference is that `f` uses `EmptyCase`,
 whereas `g` does not, and the codepath for `EmptyCase` is unfortunately
 incongruous with the codepath for other coverage checking.

 I know how to fix this. Patch incoming.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15450>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list