[GHC] #15884: Completeness of View Patterns With a Complete Set of Output Patterns

GHC ghc-devs at haskell.org
Sat Nov 10 11:07:33 UTC 2018


#15884: Completeness of View Patterns With a Complete Set of Output Patterns
-------------------------------------+-------------------------------------
        Reporter:  Shayan-Najd       |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.6.3
       Component:  Compiler          |              Version:  8.6.2
      Resolution:  duplicate         |             Keywords:
                                     |  PatternMatchWarnings
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #15753            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * status:  new => closed
 * resolution:   => duplicate
 * related:   => #15753


Comment:

 This is a duplicate of #15753 (see
 https://ghc.haskell.org/trac/ghc/ticket/15753#comment:3), so closing. In
 particular, note that this bug has nothing to do with `ViewPatterns`, as
 you can achieve the same erroneous warning with just ordinary
 `PatternGuards`:

 {{{#!hs
 {-# OPTIONS_GHC -Wall #-}
 module Bug where

  f :: Maybe a -> Bool
  f x
    | Nothing <- id x
    = False
    | Just _ <- id x
    = True
 }}}
 {{{
 $ /opt/ghc/8.6.2/bin/ghci Bug.hs
 GHCi, version 8.6.2: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/ryanglscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:5:2: warning: [-Wincomplete-patterns]
     Pattern match(es) are non-exhaustive
     In an equation for ‘f’: Patterns not matched: _
   |
 5 |  f x
   |  ^^^...
 }}}

 Removing the use of the `id` function, however, makes the warnings go
 away.

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


More information about the ghc-tickets mailing list