return when desugaring to closures

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Sun Oct 12 17:45:48 PDT 2008


Mark S. Miller wrote:
> On Sun, Oct 12, 2008 at 2:19 PM, Yuh-Ruey Chen <maian330 at gmail.com> wrote:
>> David-Sarah Hopwood wrote:
>>>   { while (...) let x = ...; }
>> I was under the impression that such statements should be disallowed,
>> following the example of JS1.8. In JS1.8 (Fx3), the following are all
>> syntax errors:
>>
>> while (...) let x = ...;
>> do let x = ...; while (...);
>> if (...) let x = ...;
>> for (...) let x = ...;
> 
> These are unconditionally disallowed starting in ES3.1 because such
> declarations are Statements but not SubStatements and only
> SubStatements are allowed by the grammar at the positions above.

Since LabelledStatement is included in SubStatement, the following is
allowed in the current ES3.1 draft:

  while (...) foo: var x = ...;

I would suggest that it shouldn't be, i.e. that LabelledStatement should
be removed from SubStatement.

[Jacaranda has similar, but stricter restrictions on substatements.
See the rationale for group SIMPLE_STATEMENTS in the Jacaranda spec,
<http://www.jacaranda.org/jacaranda-spec-0.3.txt>.]

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list