[GHC] #10180: Lint check: Empty alternatives imply bottoming scrutinee
GHC
ghc-devs at haskell.org
Mon Mar 23 09:16:15 UTC 2015
#10180: Lint check: Empty alternatives imply bottoming scrutinee
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: nomeata
Type: task | Status: infoneeded
Priority: normal | Milestone:
Component: Compiler | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by nomeata):
Hi,
Replying to [comment:3 simonpj]:
> Very interesting.
> * What program gives rise to `case (x::Void) of {}`?
Precisely that program :-)
See `Data.Void`:
{{{
absurd :: Void -> a
absurd a = case a of {}
}}}
> * Yes, I think there is a case for making `exprIsBottom` hold for data
types with no constructors; after all, such an expression is bound to
diverge.
> * A slightly less pervasive change would to to say that an empty `case`
is ok on a data type that has an empty set of constructors. Less
pervasive in the sense that it affects this Lint check only, whereas the
`exprIsBottom` fix would have broader implications: good ones, I think,
but also rare.
I’ll do that first, and afterwards look into moving the no-constructor-
test into `exprIsBottom`.
Replying to [comment:4 simonpj]:
> Replying to [comment:2 nomeata]:
> > So there is a lambda under the case, but it is a type lambda. Bogus or
not?
>
> Ha! There's a missing case in `exprIsBottom`:
> {{{
> exprIsBottom (Lam v e) | isTyVar v = exprIsBottom e
> }}}
> Well spotted.
I’ll add that and see if the linter is happy then.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10180#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list