Conversation
f4713c9 to
c1dcacc
Compare
a770bff to
283aa68
Compare
|
Hi @ariya ! Here's a PR to allow parsing about 6000 more scripts that were unparseable before, basically allowing async generators and couple more error checks. |
|
Great work @lahma, thanks! I will take a look. |
| StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', | ||
| StrictModeWith: 'Strict mode code may not include a with statement', | ||
| StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', | ||
| StrictParamDupe: 'Strict mode function may not have duplicate parameter names', |
There was a problem hiding this comment.
Removed this in favor of DuplicateParameter which aligns with V8
| allowStrictDirective: boolean; | ||
| allowYield: boolean; | ||
| await: boolean; | ||
| isAsync: boolean; |
There was a problem hiding this comment.
Renamed this as await is keyword and isAsync describes the context
| this.errorHandler.tolerate(this.unexpectedTokenError(token, message)); | ||
| } | ||
|
|
||
| tolerateInvalidLoopStatement() { |
There was a problem hiding this comment.
Had to create separate function as for statement parsing started to fail due to cyclomatic complexity
| switch (this.lookahead.type) { | ||
| case Token.Identifier: | ||
| if ((this.context.isModule || this.context.await) && this.lookahead.value === 'await') { | ||
| if ((this.context.isModule || this.context.isAsync) && this.lookahead.value === 'await') { |
There was a problem hiding this comment.
I think this now reads better, isModule, isAsync
| } | ||
|
|
||
| parsePropertyMethodAsyncFunction(): Node.FunctionExpression { | ||
| parsePropertyMethodAsyncFunction(isGenerator: boolean): Node.FunctionExpression { |
There was a problem hiding this comment.
Might make sense at some point to put isGenerator into context
There was a problem hiding this comment.
This is Boolean trap, though we already have some cases like that in the same file.
There was a problem hiding this comment.
So should I put this into context as part of this PR or what changes required?
| } | ||
|
|
||
| parseRestProperty(params, kind): Node.RestElement { | ||
| parseRestProperty(params): Node.RestElement { |
There was a problem hiding this comment.
Removed the unused parameter as style checks gave warning and couldn't see a reason to keep
| } | ||
| this.expect(')'); | ||
|
|
||
| if (options.hasDuplicateParameterNames) { |
There was a problem hiding this comment.
Moved checks to single place where can validate against context
|
@ariya anything you want me to tweak here? |
|
Thank you @lahma 👍 |
|
You're most welcome, thanks for merging! |
|
@lahma i've merged your changes also in my fork |
| expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression); | ||
| } | ||
|
|
||
| if (isSuper && this.match('(') && !this.context.inClassConstructor) { |
Async generators are valid constructs and went through issues parsing them. Couple issues surfaced on class handling side but unrelated to async generators per se.
Before
✔ 54265 valid programs parsed without error
✔ 6748 invalid programs produced a parsing error
✔ 1101 invalid programs did not produce a parsing error (and allowed by the whitelist file)
✔ 16288 valid programs produced a parsing error (and allowed by the whitelist file)
After
✔ 60262 valid programs parsed without error
✔ 6747 invalid programs produced a parsing error
✔ 1102 invalid programs did not produce a parsing error (and allowed by the whitelist file)
✔ 10291 valid programs produced a parsing error (and allowed by the whitelist file)
fixes #1990