RFE: Allow newline when returning an anonymous object

cowwoc cowwoc at bbs.darktech.org
Wed May 28 11:51:44 PDT 2014


On 28/05/2014 2:43 PM, Oliver Hunt wrote:
>> 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

Wow, what a mess. I've been pretty methodical about semicolons in my 
code so I forgot about this "feature" :)

I'm not a fan of ASI, but in light of your example I agree there is 
ambiguity. Thanks for the clarification.

You might want to consider killing off ASI one day, if "use strict" is 
enabled ;)

Gili


More information about the es-discuss mailing list