[GHC] #11475: Lint should check for inexhaustive alternatives

GHC ghc-devs at haskell.org
Mon Feb 22 10:51:25 UTC 2016


#11475: Lint should check for inexhaustive alternatives
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
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 simonpj):

 I suggest being less ambitious!  Do the simple things first.
 {{{
 case (case ... of ... -> Left x) of
    Left y -> ...
 }}}
 GHC itself is unlikely to prune the alternative in the outer case,
 precisely because it's not so obvious that the inner case can only return
 Left.
 {{{
   bar = ... case foo a b of
     (:) x y -> ...
 }}}
 Same here.

 In short, dealing with in-scope pattern matches and GADTs is worth doing
 first.

 Then when you get a false positive (which you say you are) we can think
 about them.

 (For `foo`, the `CprResult` part of the strictness signature will tell
 that `foo` only returns `(:)` but I'm a bit surprised that GHC actually
 uses this to prune the case alternatives.

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


More information about the ghc-tickets mailing list