Comparing version 6.0.18 to 6.1.2
@@ -109,13 +109,16 @@ /* @flow */ | ||
var failOnShorthandAssign = undefined; | ||
if (!refShorthandDefaultPos) { | ||
if (refShorthandDefaultPos) { | ||
failOnShorthandAssign = false; | ||
} else { | ||
refShorthandDefaultPos = { start: 0 }; | ||
failOnShorthandAssign = true; | ||
} else { | ||
failOnShorthandAssign = false; | ||
} | ||
var startPos = this.state.start, | ||
startLoc = this.state.startLoc; | ||
var startPos = this.state.start; | ||
var startLoc = this.state.startLoc; | ||
if (this.match(_tokenizerTypes.types.parenL) || this.match(_tokenizerTypes.types.name)) { | ||
this.state.potentialArrowAt = this.state.start; | ||
} | ||
var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos); | ||
@@ -128,3 +131,5 @@ if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc); | ||
refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly | ||
this.checkLVal(left); | ||
if (left.extra && left.extra.parenthesized) { | ||
@@ -141,2 +146,3 @@ var errorMsg = undefined; | ||
} | ||
this.next(); | ||
@@ -148,2 +154,3 @@ node.right = this.parseMaybeAssign(noIn); | ||
} | ||
return left; | ||
@@ -534,2 +541,3 @@ }; | ||
startLoc = startLoc || this.state.startLoc; | ||
var val = undefined; | ||
@@ -544,3 +552,2 @@ this.next(); | ||
spreadStart = undefined, | ||
innerParenStart = undefined, | ||
optionalCommaStart = undefined; | ||
@@ -565,5 +572,2 @@ while (!this.match(_tokenizerTypes.types.parenR)) { | ||
} else { | ||
if (this.match(_tokenizerTypes.types.parenL) && !innerParenStart) { | ||
innerParenStart = this.state.start; | ||
} | ||
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem)); | ||
@@ -578,3 +582,7 @@ } | ||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokenizerTypes.types.arrow)) { | ||
if (innerParenStart) this.unexpected(innerParenStart); | ||
for (var _i = 0; _i < exprList.length; _i++) { | ||
var param = exprList[_i]; | ||
if (param.extra && param.extra.parenthesized) this.unexpected(param.extra.parenStart); | ||
} | ||
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, isAsync); | ||
@@ -602,3 +610,6 @@ } | ||
} | ||
this.addExtra(val, "parenthesized", true); | ||
this.addExtra(val, "parenStart", startPos); | ||
return val; | ||
@@ -731,2 +742,3 @@ }; | ||
isAsync = true; | ||
if (this.hasPlugin("asyncGenerators")) isGenerator = this.eat(_tokenizerTypes.types.star); | ||
this.parsePropertyName(prop); | ||
@@ -892,12 +904,12 @@ } | ||
if (!isExpression && node.body.directives.length) { | ||
for (var _iterator = (node.body.directives /*: Array<Object>*/), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _getIterator(_iterator);;) { | ||
for (var _iterator = (node.body.directives /*: Array<Object>*/), _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _getIterator(_iterator);;) { | ||
var _ref; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
if (_i2 >= _iterator.length) break; | ||
_ref = _iterator[_i2++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
_i2 = _iterator.next(); | ||
if (_i2.done) break; | ||
_ref = _i2.value; | ||
} | ||
@@ -928,12 +940,12 @@ | ||
} | ||
for (var _iterator2 = (node.params /*: Array<Object>*/), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _getIterator(_iterator2);;) { | ||
for (var _iterator2 = (node.params /*: Array<Object>*/), _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _getIterator(_iterator2);;) { | ||
var _ref2; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
if (_i3 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i3++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
_i3 = _iterator2.next(); | ||
if (_i3.done) break; | ||
_ref2 = _i3.value; | ||
} | ||
@@ -940,0 +952,0 @@ |
@@ -47,4 +47,2 @@ /* @flow */ | ||
if (prop.type === "SpreadProperty") continue; | ||
if (prop.type === "ObjectMethod") { | ||
@@ -56,10 +54,16 @@ if (prop.kind === "get" || prop.kind === "set") { | ||
} | ||
} else { | ||
this.toAssignable(prop, isBinding); | ||
} | ||
if (prop.type === "ObjectProperty") { | ||
this.toAssignable(prop.value, isBinding); | ||
} | ||
} | ||
break; | ||
case "ObjectProperty": | ||
this.toAssignable(node.value, isBinding); | ||
break; | ||
case "SpreadProperty": | ||
node.type = "RestProperty"; | ||
break; | ||
case "ArrayExpression": | ||
@@ -66,0 +70,0 @@ node.type = "ArrayPattern"; |
@@ -78,3 +78,3 @@ /* @flow */ | ||
pp.semicolon = function () { | ||
if (!this.eat(_tokenizerTypes.types.semi) && !this.canInsertSemicolon()) this.unexpected(); | ||
if (!this.isLineTerminator()) this.unexpected(); | ||
}; | ||
@@ -81,0 +81,0 @@ |
@@ -175,3 +175,3 @@ /* @flow */ | ||
while (!this.isRelational(">")) { | ||
node.params.push(this.flowParseTypeAnnotatableIdentifier()); | ||
node.params.push(this.flowParseExistentialTypeParam() || this.flowParseTypeAnnotatableIdentifier()); | ||
if (!this.isRelational(">")) { | ||
@@ -186,2 +186,10 @@ this.expect(_tokenizerTypes.types.comma); | ||
pp.flowParseExistentialTypeParam = function () { | ||
if (this.match(_tokenizerTypes.types.star)) { | ||
var node = this.startNode(); | ||
this.next(); | ||
return this.finishNode(node, "ExistentialTypeParam"); | ||
} | ||
}; | ||
pp.flowParseTypeParameterInstantiation = function () { | ||
@@ -196,3 +204,3 @@ var node = this.startNode(), | ||
while (!this.isRelational(">")) { | ||
node.params.push(this.flowParseType()); | ||
node.params.push(this.flowParseExistentialTypeParam() || this.flowParseType()); | ||
if (!this.isRelational(">")) { | ||
@@ -764,2 +772,12 @@ this.expect(_tokenizerTypes.types.comma); | ||
instance.extend("toAssignable", function (inner) { | ||
return function (node) { | ||
if (node.type === "TypeCastExpression") { | ||
return typeCastToParameter(node); | ||
} else { | ||
return inner.apply(this, arguments); | ||
} | ||
}; | ||
}); | ||
// turn type casts that we found in function parameter head into type annotated params | ||
@@ -810,2 +828,10 @@ instance.extend("toAssignableList", function (inner) { | ||
instance.extend("checkLVal", function (inner) { | ||
return function (node) { | ||
if (node.type !== "TypeCastExpression") { | ||
return inner.apply(this, arguments); | ||
} | ||
}; | ||
}); | ||
// parse class property type annotations | ||
@@ -812,0 +838,0 @@ instance.extend("parseClassProperty", function (inner) { |
@@ -15,2 +15,4 @@ /* @flow */ | ||
var _utilWhitespace = require("../util/whitespace"); | ||
var TokContext = function TokContext(token /*: string*/, isExpr /*:: ?: boolean*/, preserveSpace /*:: ?: boolean*/, override /*:: ?: Function*/) { | ||
@@ -58,2 +60,12 @@ _classCallCheck(this, TokContext); | ||
_types.types.name.updateContext = function (prevType) { | ||
this.state.exprAllowed = false; | ||
if (prevType === _types.types._let || prevType === _types.types._const || prevType === _types.types._var) { | ||
if (_utilWhitespace.lineBreak.test(this.input.slice(this.state.end))) { | ||
this.state.exprAllowed = true; | ||
} | ||
} | ||
}; | ||
_types.types.braceL.updateContext = function (prevType) { | ||
@@ -60,0 +72,0 @@ this.state.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr); |
{ | ||
"name": "babylon", | ||
"version": "6.0.18", | ||
"version": "6.1.2", | ||
"description": "A JavaScript parser", | ||
@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198096
5039