logo       

Re: GHC rejects empty case: msg#00083

lang.haskell.glasgow.bugs

Subject: Re: GHC rejects empty case

On Sun, Mar 30, 2003 at 08:38:42PM +0300, Lauri Alanko wrote:
> The H98 report says:
>
> exp -> case exp of { alts }
> alts -> alt1 ; ... ; altn (n>=1)
> alt -> pat -> exp [where decls]
> | pat gdpat [where decls]
> | (empty alternative)
>
> Since an alt can be empty, these ought to be legal:
>
> case e of { }
> case e of { ; }
>
> However, GHC 5.04.2 rejects them ("parse error on input `}'"). The
> report also says:
>
> A case expression must have at least one alternative and each
> alternative must have at least one body.
>
> But this "at least one body" rule, if strictly interpreted, seems to
> contradict the "empty alternative" production.

No, it just imposes the further restriction that not all alternatives
can be empty. It's not the only place in the report that the text
adds restrictions beyond the context-free grammar.

> So I don't see why a
> case expression consisting of _only_ empty alternatives couldn't be
> accepted.

It would require a special type rule, just for another way of writing
undefined.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise