Fix #336 by correctly setting arrow-param (#337)

This commit is contained in:
Daniel Tschinder
2017-02-10 15:01:39 +01:00
committed by GitHub
parent 88d38a1abb
commit bc771bd0f9
4 changed files with 255 additions and 5 deletions

View File

@@ -343,7 +343,7 @@ pp.parseCallExpressionArguments = function (close, possibleAsyncArrow) {
innerParenStart = this.state.start;
}
elts.push(this.parseExprListItem(undefined, possibleAsyncArrow ? { start: 0 } : undefined));
elts.push(this.parseExprListItem(false, possibleAsyncArrow ? { start: 0 } : undefined, possibleAsyncArrow ? { start: 0 } : undefined));
}
// we found an async arrow function so let's not allow any inner parens
@@ -1021,14 +1021,14 @@ pp.parseExprList = function (close, allowEmpty, refShorthandDefaultPos) {
return elts;
};
pp.parseExprListItem = function (allowEmpty, refShorthandDefaultPos) {
pp.parseExprListItem = function (allowEmpty, refShorthandDefaultPos, refNeedsArrowPos) {
let elt;
if (allowEmpty && this.match(tt.comma)) {
elt = null;
} else if (this.match(tt.ellipsis)) {
elt = this.parseSpread(refShorthandDefaultPos);
} else {
elt = this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem);
elt = this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos);
}
return elt;
};

View File

@@ -1087,9 +1087,9 @@ export default function (instance) {
// parse an item inside a expression list eg. `(NODE, NODE)` where NODE represents
// the position where this function is called
instance.extend("parseExprListItem", function (inner) {
return function (allowEmpty, refShorthandDefaultPos) {
return function (...args) {
const container = this.startNode();
const node = inner.call(this, allowEmpty, refShorthandDefaultPos);
const node = inner.call(this, ...args);
if (this.match(tt.colon)) {
container._exprListItem = true;
container.expression = node;