esprima-dotnet: Parser error on Asynchronous iteration and Asynchronous generators

The parser has issues with the aforementioned ES2018 features:

  • Asynchronous iteration works only when ParserOptions.Tolerant is set to false, otherwise it results in ParserException. Sample input:

    for await (const x of syncToAsyncIterable(['a', 'b'])) {
      console.log(x);
    }
    

    results in error as expected but is parsed fine in async contexts:

     async function f() {
       for await (const x of syncToAsyncIterable(['a', 'b'])) {
         console.log(x);
       }
     }
    
  • Asynchronous generators results in in ParserException regardless the ParserOptions.Tolerant setting. Sample input:

    async function* asyncGen() {
      yield someValue;
    }
    

Library version: 2.0.2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve merged in the changes as the JS PR seems to be in standstill. Your three examples provided in summary now parse without errors. Let’s iterate more later if needed…

I’ve completed the changes on JS side and also have the relevant code on .NET side ready (actually developed on .NET sided as debugging is waaaay easier). Waiting for acceptance there.

Here’s the draft PR on C# side, I’m working on both JS and C# to see how the implementation works: https://github.com/sebastienros/esprima-dotnet/pull/190

@lahma I can take the other issue (the minor strict mode bug) but I’m not familiar enough with the parser to tackle this one.