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

Claude Pache claude.pache at gmail.com
Mon Feb 22 17:22:29 UTC 2016


> 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