
#11245: Non-exhaustive pattern, "Patterns not matched" list is empty -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Example: {{{#!haskell module Main where maybeOdd :: Int -> Maybe Int maybeOdd i = if odd i then Just i else Nothing main :: IO () main = do let x = maybeOdd 10 let a | Just i <- x , odd i = True | Nothing <- x = False print x print a }}} Warning printed by GHC HEAD: {{{ Exhaustive.hs:10:7: warning: Pattern match(es) are non-exhaustive In an equation for ‘a’: Patterns not matched: Linking Exhaustive ... }}} The problem with this message is; if it couldn't come up with an example unmatched pattern, then how can it know that the pattern is non- exhaustive? If it came up with an example, why is that example not printed? UPDATE: I just realized it's actually worse that I first thought. If I change {{{a}}} in this example: {{{#!haskell let a | Just i <- x = True }}} This message is printed: {{{ [1 of 1] Compiling Main ( Exhaustive.hs, Exhaustive.o ) Exhaustive.hs:10:7: warning: Pattern match(es) are non-exhaustive In an equation for ‘a’: Patterns not matched: Exhaustive.hs:10:16: warning: Defined but not used: ‘i’ Linking Exhaustive ... }}} NOTE: Tried with GHC 7.10 too. It seems like in the case where the checks are not exhaustive, both 7.10 and HEAD are giving the same warning(with empty list of non-checked patterns). HEAD is better in detecting exhaustive patterns. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11245 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler