Refactor [In] production parameter tracking (#11930)
* refactor: track [In] parameter in prodParam * Apply suggestions from code review
This commit is contained in:
@@ -1816,7 +1816,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
parseConditional(
|
||||
expr: N.Expression,
|
||||
noIn: ?boolean,
|
||||
startPos: number,
|
||||
startLoc: Position,
|
||||
refNeedsArrowPos?: ?Pos,
|
||||
@@ -1827,7 +1826,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// and if we come from inside parens
|
||||
if (refNeedsArrowPos) {
|
||||
const result = this.tryParse(() =>
|
||||
super.parseConditional(expr, noIn, startPos, startLoc),
|
||||
super.parseConditional(expr, startPos, startLoc),
|
||||
);
|
||||
|
||||
if (!result.node) {
|
||||
@@ -1886,7 +1885,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.test = expr;
|
||||
node.consequent = consequent;
|
||||
node.alternate = this.forwardNoArrowParamsConversionAt(node, () =>
|
||||
this.parseMaybeAssign(noIn, undefined, undefined, undefined),
|
||||
this.parseMaybeAssign(undefined, undefined, undefined),
|
||||
);
|
||||
|
||||
return this.finishNode(node, "ConditionalExpression");
|
||||
@@ -1898,7 +1897,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
} {
|
||||
this.state.noArrowParamsConversionAt.push(this.state.start);
|
||||
|
||||
const consequent = this.parseMaybeAssign();
|
||||
const consequent = this.parseMaybeAssignAllowIn();
|
||||
const failed = !this.match(tt.colon);
|
||||
|
||||
this.state.noArrowParamsConversionAt.pop();
|
||||
@@ -2632,7 +2631,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// there
|
||||
// 3. This is neither. Just call the super method
|
||||
parseMaybeAssign(
|
||||
noIn?: ?boolean,
|
||||
refExpressionErrors?: ?ExpressionErrors,
|
||||
afterLeftParse?: Function,
|
||||
refNeedsArrowPos?: ?Pos,
|
||||
@@ -2650,7 +2648,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
jsx = this.tryParse(
|
||||
() =>
|
||||
super.parseMaybeAssign(
|
||||
noIn,
|
||||
refExpressionErrors,
|
||||
afterLeftParse,
|
||||
refNeedsArrowPos,
|
||||
@@ -2684,7 +2681,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
typeParameters,
|
||||
() =>
|
||||
super.parseMaybeAssign(
|
||||
noIn,
|
||||
refExpressionErrors,
|
||||
afterLeftParse,
|
||||
refNeedsArrowPos,
|
||||
@@ -2730,7 +2726,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
return super.parseMaybeAssign(
|
||||
noIn,
|
||||
refExpressionErrors,
|
||||
afterLeftParse,
|
||||
refNeedsArrowPos,
|
||||
|
||||
@@ -356,7 +356,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const node = this.startNode();
|
||||
if (this.eat(tt.braceL)) {
|
||||
this.expect(tt.ellipsis);
|
||||
node.argument = this.parseMaybeAssign();
|
||||
node.argument = this.parseMaybeAssignAllowIn();
|
||||
this.expect(tt.braceR);
|
||||
return this.finishNode(node, "JSXSpreadAttribute");
|
||||
}
|
||||
|
||||
@@ -1285,7 +1285,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
? this.parseExprAtom()
|
||||
: this.parseIdentifier(/* liberal */ true);
|
||||
if (this.eat(tt.eq)) {
|
||||
node.initializer = this.parseMaybeAssign();
|
||||
node.initializer = this.parseMaybeAssignAllowIn();
|
||||
}
|
||||
return this.finishNode(node, "TSEnumMember");
|
||||
}
|
||||
@@ -1865,7 +1865,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
leftStartPos: number,
|
||||
leftStartLoc: Position,
|
||||
minPrec: number,
|
||||
noIn: ?boolean,
|
||||
) {
|
||||
if (
|
||||
nonNull(tt._in.binop) > minPrec &&
|
||||
@@ -1886,16 +1885,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
this.finishNode(node, "TSAsExpression");
|
||||
// rescan `<`, `>` because they were scanned when this.state.inType was true
|
||||
this.reScan_lt_gt();
|
||||
return this.parseExprOp(
|
||||
node,
|
||||
leftStartPos,
|
||||
leftStartLoc,
|
||||
minPrec,
|
||||
noIn,
|
||||
);
|
||||
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
|
||||
}
|
||||
|
||||
return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn);
|
||||
return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec);
|
||||
}
|
||||
|
||||
checkReservedWord(
|
||||
@@ -2135,7 +2128,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// An apparent conditional expression could actually be an optional parameter in an arrow function.
|
||||
parseConditional(
|
||||
expr: N.Expression,
|
||||
noIn: ?boolean,
|
||||
startPos: number,
|
||||
startLoc: Position,
|
||||
refNeedsArrowPos?: ?Pos,
|
||||
@@ -2145,7 +2137,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (!refNeedsArrowPos || !this.match(tt.question)) {
|
||||
return super.parseConditional(
|
||||
expr,
|
||||
noIn,
|
||||
startPos,
|
||||
startLoc,
|
||||
refNeedsArrowPos,
|
||||
@@ -2153,7 +2144,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
const result = this.tryParse(() =>
|
||||
super.parseConditional(expr, noIn, startPos, startLoc),
|
||||
super.parseConditional(expr, startPos, startLoc),
|
||||
);
|
||||
|
||||
if (!result.node) {
|
||||
|
||||
Reference in New Issue
Block a user