`do` expression conflicting with `do ... while` grammar?

Caitlin Potter caitpotter88 at gmail.com
Mon Feb 22 17:33:04 UTC 2016


oh, somehow I totally missed the 'while (true)' at the end of that snippet -- so I retract the SyntaxError thing. but yeah, would be a do-while loop

> On Feb 22, 2016, at 12:22 PM, Claude Pache <claude.pache at gmail.com> wrote:
> 
> 
>> Le 22 févr. 2016 à 17:47, Bradley Meck <bradley.meck at gmail.com> a écrit :
>> 
>> Does that mean the following would parse as a do expression?
>> 
>> ```javascript
>> function foo () {
>>  return
>>  do {
>>    1;
>>  }
>>  while (true);
>> }
>> ```
> 
> No, because `return` cannot be followed be a LineTerminator, so that ASI will introduce a semicolon after it.
> 
> This is the same issue as:
> 
> ```js
> function foo() {
>    return   // an implied semicolon is inserted here
>    { bar: 1 }; // interpreted as a block, not as an object literal
> }
> ```
> 
> —Claude


More information about the es-discuss mailing list