#2006: unreachable GADT pattern clauses show up as warnings with -Wall
-------------------------+--------------------------------------------------
    Reporter:  ryani     |       Owner:         
        Type:  bug       |      Status:  new    
    Priority:  normal    |   Milestone:         
   Component:  Compiler  |     Version:  6.8.1  
    Severity:  normal    |    Keywords:         
  Difficulty:  Unknown   |    Testcase:         
Architecture:  Unknown   |          Os:  Unknown
-------------------------+--------------------------------------------------
 In the following code, there is a line commented out.  With it commented
 out, I get the following warning:

 {{{
 patternbug.hs:10:0:
     Warning: Pattern match(es) are non-exhaustive
              In the definition of `interpret': Patterns not matched: EVar
 }}}

 With it uncommented, I get the following compiler error:
 {{{
 patternbug.hs:11:10:
     Inaccessible case alternative: Can't match types `()' and `(a, vs)'
     In the pattern: EVar
     In the definition of `interpret':
         interpret EVar = error "unreachable"
 }}}

 The exhaustive pattern-matching algorithm should ignore unreachable cases
 in its analysis.

 {{{
 {-# OPTIONS_GHC -Wall #-}
 {-# LANGUAGE GADTs #-}
 module PatternBug where

 data Expr a vs where
     EPrim   :: String -> a -> Expr a vs
     EVar    :: Expr a (a,vs)

 interpret :: Expr a () -> a
 interpret (EPrim _ a) = a
 -- interpret EVar = error "unreachable"
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2006>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to