[GHC] #15385: -Wincomplete-patterns gets confused when combining GADTs and pattern guards

GHC ghc-devs at haskell.org
Sun Jul 15 17:38:07 UTC 2018


#15385: -Wincomplete-patterns gets confused when combining GADTs and pattern guards
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
                                     |  PatternMatchWarnings
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Actually, this is even simpler than I made it out to be:

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

 import Data.Type.Equality

 data T a where
   TInt  :: T Int
   TBool :: T Bool

 f :: a :~: Int -> T a -> ()
 f eq t
   | Refl <- eq
   = case t of
       TInt -> ()
       -- TBool -> ()
 }}}

 {{{
 GHCi, version 8.6.0.20180627: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug3.hs, interpreted )

 Bug3.hs:15:5: warning: [-Wincomplete-patterns]
     Pattern match(es) are non-exhaustive
     In a case alternative: Patterns not matched: TBool
    |
 15 |   = case t of
    |     ^^^^^^^^^...
 }}}

 Stunning.

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


More information about the ghc-tickets mailing list