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

GHC ghc-devs at haskell.org
Thu Mar 10 09:07:49 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):

 Ah yes, that is tricky.  I'm really not sure how far it is profitable to
 go here.  That is, when does keeping Lint happy become burdensome?

 But let me suggest a possible approach for this particular case.

 * Ids have Unfoldings inside them.  One such is `OtherCon [AltCon]` (see
 `CoreSyn`) which says "this Id does not match any of these constructors".

 * Since they are Ids even lambda-bound variables may have unfoldings.  I'm
 in two minds about whether this is a good idea, but you could give the
 `\y` in the defn of `lvl` above a `OtherCon[A,B]` unfolding.  Then you
 wouldn't get a Lint error from the `case` in `lvl`.

 * But in exchange you'd have a new thing to check: that `lvl` was indeed
 applied to arguments that were not `A` or `B`.  So I'm not sure we are any
 further forward.

 Maybe this can only be done with a better flow analysis... a "super-Lint"
 if you like.

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


More information about the ghc-tickets mailing list