[GHC] #8494: Warn if a pattern guard obviates all others

GHC ghc-devs at haskell.org
Fri Nov 1 05:06:14 UTC 2013


#8494: Warn if a pattern guard obviates all others
-------------------------+-------------------------------------------------
       Reporter:         |             Owner:
  JohnWiegley            |            Status:  new
           Type:         |         Milestone:
  feature request        |           Version:  7.6.3
       Priority:         |  Operating System:  Unknown/Multiple
  normal                 |   Type of failure:  Incorrect warning at
      Component:         |  compile-time
  Compiler               |         Test Case:
       Keywords:         |          Blocking:
   Architecture:         |
  Unknown/Multiple       |
     Difficulty:         |
  Unknown                |
     Blocked By:         |
Related Tickets:         |
-------------------------+-------------------------------------------------
 The following code, when compiled with `-Wall`, gives no warnings:

 {{{
 module Main where

 main :: IO ()
 main = print $ foo (10 :: Int)
   where
     foo x
         | True = (20 :: Int)
         | x == 10 = (30 :: Int)
 }}}

 I would expect that since the pattern guard `| True` obviates the
 following guards, that it would warn about unreachable code.  There was a
 bug in my code today which I tracked down to a code transposition that
 would have been easily spotted with such a warning.

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


More information about the ghc-tickets mailing list