id have to check the ASI rules, but I expect that would parse as a do-while 
loop and result in a SyntaxError. Interesting test case, though. should add to 
v8's test suite.

> On Feb 22, 2016, at 11:47 AM, Bradley Meck <[email protected]> wrote:
> 
> Does that mean the following would parse as a do expression?
> 
> ```javascript
> function foo () {
>   return
>   do {
>     1;
>   }
>   while (true);
> }
> ```
> 
>> On Mon, Feb 22, 2016 at 10:43 AM, Caitlin Potter <[email protected]> 
>> wrote:
>> current impl in v8 is to only parse do-expressions in expression contexts 
>> (as a PrimaryExpr, iirc). So it never gets mixed up with do-while loops, 
>> which is fine (imo).
>> 
>> I recall seeing discussion about this in tc39 notes at some point, afaik the 
>> conclusion was that do-expressions dont work in Statement contexts, because 
>> theres no use case
>> 
>> > On Feb 22, 2016, at 11:38 AM, Bradley Meck <[email protected]> wrote:
>> >
>> > how will people distinguish `do ... while` from `do` expressions? I tried 
>> > to find the exact grammar but couldn't after a bit of searching.
>> >
>> > For example in current JS,
>> >
>> > ```
>> > do {
>> >   console.log(1);
>> > }
>> > while (true);
>> > ```
>> >
>> > would cause infinite number of `console.log`s. But if the `do` is seen as 
>> > an expression statement it would only log once.
>> >
>> > Any pointer to where the grammar is discussed would be quite helpful.
>> > _______________________________________________
>> > es-discuss mailing list
>> > [email protected]
>> > https://mail.mozilla.org/listinfo/es-discuss
> 
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to