Fix and tests

This commit is contained in:
Julian Viereck
2016-01-31 01:22:31 +01:00
parent 97fd9d65e7
commit a121d1b7b5
5 changed files with 210 additions and 3 deletions

View File

@@ -528,7 +528,7 @@ pp.parseParenExpression = function () {
return val;
};
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync) {
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync, allowOptionalCommaStart) {
startPos = startPos || this.state.start;
startLoc = startLoc || this.state.startLoc;
@@ -578,7 +578,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
this.unexpected(this.state.lastTokStart);
}
}
if (optionalCommaStart) this.unexpected(optionalCommaStart);
if (optionalCommaStart && !allowOptionalCommaStart) this.unexpected(optionalCommaStart);
if (spreadStart) this.unexpected(spreadStart);
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);

View File

@@ -1030,7 +1030,7 @@ export default function (instance) {
return this.parseArrowExpression(node, [], isAsync);
} else {
// let foo = (foo): number => {};
let node = inner.call(this, startPos, startLoc, canBeArrow, isAsync);
let node = inner.call(this, startPos, startLoc, canBeArrow, isAsync, this.hasPlugin("trailingFunctionCommas"));
if (this.match(tt.colon)) {
let state = this.state.clone();