[GHC] #11390: GHC does not warn about redundant patterns
GHC
ghc-devs at haskell.org
Sat Jan 9 17:47:17 UTC 2016
#11390: GHC does not warn about redundant patterns
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords: warnings
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Iceland_jack):
I thought that was what the documentation for `EmptyCase` is alluding to:
> With dependently-typed features it is more useful (see Trac #2431). For
example, consider these two candidate definitions of absurd:
>
> {{{#!hs
> data a :==: b where
> Refl :: a :==: a
>
> absurd :: True :~: False -> a
> absurd x = error "absurd" -- (A)
> absurd x = case x of {} -- (B)
> }}}
>
> We much prefer (B). Why? Because GHC can figure out that `(True :~:
False)` is an empty type. So (B) has no partiality and GHC should be able
to compile with [http://downloads.haskell.org/~ghc/master/users-guide
/using-warnings.html#ghc-flag--Wincomplete-patterns -Wincomplete-
patterns]. (Though the pattern match checking is not yet clever enough to
do that.) On the other hand (A) looks dangerous, and GHC doesn’t check to
make sure that, in fact, the function can never get called.
I wasn't sure whether the "Though the pattern match checking is not yet
clever enough to do that." statement had changed in 8, I'll edit the code
to enable `LambdaCase` as well.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11390#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list