Parses flow type cast expression with parenthesis in call expression correctly #446
Conversation
Codecov Report
@@ Coverage Diff @@
## master #446 +/- ##
==========================================
+ Coverage 98.25% 98.41% +0.15%
==========================================
Files 20 20
Lines 3504 3526 +22
Branches 927 934 +7
==========================================
+ Hits 3443 3470 +27
+ Misses 22 18 -4
+ Partials 39 38 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this could be fixed without changing the parsing to rely on the lookahead?
@@ -298,22 +323,23 @@ pp.parseSubscripts = function (base, startPos, startLoc, noCalls) { | |||
this.expect(tt.bracketR); | |||
base = this.finishNode(node, "MemberExpression"); | |||
} else if (!noCalls && this.match(tt.parenL)) { | |||
const possibleAsync = this.state.potentialArrowAt === base.start && base.type === "Identifier" && base.name === "async" && !this.canInsertSemicolon(); | |||
const old = this.state.clone(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit worried about this and doing it whenever we encounter a parenL. clone() is very expensive and we have never done lookaheads of this extend before (besides one token with this.lookahead()
).
It is almost certainly possible to fix this without using parser lookahead. See wcjohnson@322842a for an outline of an approach. Basic outline:
|
We moved babylon back into the monorepo at https://github.com/babel/babel/tree/master/packages/babylon. Unfortunately pull requests cannot be migrated between repositories automatically. If this PR is still valid please reopen it there. |
By the way, now the async arrow expression is not parsed from call expression any more. Instead, check if
async
is a keyword or function name there. Then decides to parse call expression arguments or function params.