RFE: Allow newline when returning an anonymous object

Oliver Hunt oliver at apple.com
Wed May 28 11:43:11 PDT 2014


> On May 28, 2014, at 11:39 AM, cowwoc <cowwoc at bbs.darktech.org> wrote:
> 
> 
> 
> Don't we use a semicolon to denote the end of an expression context? Perhaps I'm missing something, but I see no ambiguity in the example you gave. I expect:
> 
>   return {};
> 
> and
> 
>   return
>   {};
> 
> to return an object literal, whereas:
> 
>   return; {}
> 
> or
> 
>   return;
>   {}
> 
> denote a return expression followed by a block.

No, the semicolon is not relevant as it is optional, the rules for ASI result in

return
{}

being converted to 
return ; 
{};

If you remove the newline restriction from return then ASI becomes ambiguous as well.

--Oliver

> 
> Gili



More information about the es-discuss mailing list