[GHC] #851: Incomplete-pattern checking for n+k patterns is not implemented

GHC trac at galois.com
Tue Aug 8 10:51:35 EDT 2006


#851: Incomplete-pattern checking for n+k patterns is not implemented
-------------------------+--------------------------------------------------
    Reporter:  simonpj   |        Owner:         
        Type:  bug       |       Status:  new    
    Priority:  normal    |    Milestone:         
   Component:  Compiler  |      Version:  6.4.2  
    Severity:  normal    |     Keywords:         
          Os:  Unknown   |   Difficulty:  Unknown
Architecture:  Unknown   |  
-------------------------+--------------------------------------------------
The check for incomplete patterns does not understand about n+k patterns.
 Here's an example:
 {{{
 f 0     = True
 f (n+1) = False
 }}}
 GHC says, rather confusingly:
 {{{
     Warning: Pattern match(es) are non-exhaustive
              In the definition of `f':
                  Patterns not matched: #x with #x `notElem` [0#]
 }}}
 The reason is in {{{compiler/deSugar/Check.hs}}} which says
 {{{
         -- Horrible hack.  The simplify_pat stuff converts NPlusK pats to
 WildPats
         -- which of course loses the info that they can fail to match.  So
 we
         -- stick in a CanFail as if it were a guard.
         -- The Right Thing to do is for the whole system to treat NPlusK
 pats properly
 }}}
 See ticket:595

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


More information about the Glasgow-haskell-bugs mailing list