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

#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

#8494: Warn if a pattern guard obviates all others -------------------------------------------------+------------------------- Reporter: JohnWiegley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect warning at | Unknown/Multiple compile-time | Difficulty: Test Case: | Unknown Blocking: | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Comment (by hvr): Are you just interested in warning for the case of a reduced constant expression (such as `True`)? Or shall the compiler warn about dead code in general as soon as it is detected (in the case above, when compiling with -O, the following guards are optimized away when looking at Core)? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8494#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8494: Warn if a pattern guard obviates all others -------------------------------------------------+------------------------- Reporter: JohnWiegley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect warning at | Unknown/Multiple compile-time | Difficulty: Test Case: | Unknown Blocking: | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Comment (by JohnWiegley): The ticket is only about the case of reduced constant expressions, although dead code in general would be interesting to know about. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8494#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8494: Warn if a pattern guard obviates all others -------------------------------------+------------------------------------- Reporter: JohnWiegley | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: duplicate | Keywords: | PatternMatchWarnings Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => PatternMatchWarnings -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8494#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC