Comparing version 4.0.1 to 4.0.2
@@ -0,1 +1,10 @@ | ||
## 4.0.2 (2016-08-11) | ||
### Bug fixes | ||
Don't ignore period or 'e' characters after octal numbers. | ||
Fix broken parsing for call expressions in default parameter values | ||
of arrow functions. | ||
## 4.0.1 (2016-08-08) | ||
@@ -32,4 +41,4 @@ | ||
Support for trailing commas in call expressions when `ecmaVersion` is | ||
>= 8. | ||
Support for trailing commas in call expressions when `ecmaVersion` | ||
is >= 8. | ||
@@ -36,0 +45,0 @@ ## 3.3.0 (2016-07-25) |
@@ -7,3 +7,3 @@ { | ||
"jsnext:main": "dist/acorn.es.js", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=0.4.0" |
@@ -65,3 +65,3 @@ # Acorn | ||
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be | ||
either 3, 5, 6 (2015) or 7 (2016). This influences support for strict | ||
either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support for strict | ||
mode, the set of reserved words, and support for new syntax features. | ||
@@ -68,0 +68,0 @@ Default is 7. |
@@ -94,3 +94,3 @@ // A recursive descent parser operates by defining functions for all | ||
pp.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { | ||
if (this.inGenerator && this.isContextual("yield")) return this.parseYield(refDestructuringErrors) | ||
if (this.inGenerator && this.isContextual("yield")) return this.parseYield() | ||
@@ -109,2 +109,3 @@ let ownDestructuringErrors = false | ||
this.checkPatternErrors(refDestructuringErrors, true) | ||
if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors) | ||
let node = this.startNodeAt(startPos, startLoc) | ||
@@ -116,4 +117,3 @@ node.operator = this.value | ||
this.next() | ||
node.right = this.parseMaybeAssign(noIn, refDestructuringErrors) | ||
if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true) | ||
node.right = this.parseMaybeAssign(noIn) | ||
return this.finishNode(node, "AssignmentExpression") | ||
@@ -135,5 +135,5 @@ } else { | ||
node.test = expr | ||
node.consequent = this.parseMaybeAssign(false, refDestructuringErrors) | ||
node.consequent = this.parseMaybeAssign() | ||
this.expect(tt.colon) | ||
node.alternate = this.parseMaybeAssign(noIn, refDestructuringErrors) | ||
node.alternate = this.parseMaybeAssign(noIn) | ||
return this.finishNode(node, "ConditionalExpression") | ||
@@ -150,3 +150,3 @@ } | ||
if (this.checkExpressionErrors(refDestructuringErrors)) return expr | ||
return this.parseExprOp(expr, startPos, startLoc, -1, noIn, refDestructuringErrors) | ||
return this.parseExprOp(expr, startPos, startLoc, -1, noIn) | ||
} | ||
@@ -160,3 +160,3 @@ | ||
pp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn, refDestructuringErrors) { | ||
pp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) { | ||
let prec = this.type.binop | ||
@@ -169,5 +169,5 @@ if (prec != null && (!noIn || this.type !== tt._in)) { | ||
let startPos = this.start, startLoc = this.startLoc | ||
let right = this.parseExprOp(this.parseMaybeUnary(refDestructuringErrors, false), startPos, startLoc, prec, noIn, refDestructuringErrors) | ||
let right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn) | ||
let node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical) | ||
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn, refDestructuringErrors) | ||
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) | ||
} | ||
@@ -198,3 +198,3 @@ } | ||
this.next() | ||
node.argument = this.parseMaybeUnary(refDestructuringErrors, true) | ||
node.argument = this.parseMaybeUnary(null, true) | ||
this.checkExpressionErrors(refDestructuringErrors, true) | ||
@@ -222,3 +222,3 @@ if (update) this.checkLVal(node.argument) | ||
if (!sawUnary && this.eat(tt.starstar)) | ||
return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(refDestructuringErrors, false), "**", false) | ||
return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) | ||
else | ||
@@ -235,6 +235,6 @@ return expr | ||
if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr | ||
return this.parseSubscripts(expr, startPos, startLoc, false, refDestructuringErrors) | ||
return this.parseSubscripts(expr, startPos, startLoc) | ||
} | ||
pp.parseSubscripts = function(base, startPos, startLoc, noCalls, refContextDestructuringErrors) { | ||
pp.parseSubscripts = function(base, startPos, startLoc, noCalls) { | ||
for (;;) { | ||
@@ -251,3 +251,3 @@ let maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && !this.canInsertSemicolon() | ||
node.object = base | ||
node.property = this.parseExpression(false, refContextDestructuringErrors) | ||
node.property = this.parseExpression() | ||
node.computed = true | ||
@@ -257,14 +257,16 @@ this.expect(tt.bracketR) | ||
} else if (!noCalls && this.eat(tt.parenL)) { | ||
let refDestructuringErrors = new DestructuringErrors | ||
let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos | ||
this.yieldPos = 0 | ||
this.awaitPos = 0 | ||
let exprList = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors) | ||
if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) { | ||
this.checkPatternErrors(refDestructuringErrors, true) | ||
this.checkDefaultValueErrors(refDestructuringErrors, true, true) | ||
this.checkYieldAwaitInDefaultParams() | ||
this.yieldPos = oldYieldPos | ||
this.awaitPos = oldAwaitPos | ||
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true) | ||
} | ||
this.checkExpressionErrors(refDestructuringErrors, true) | ||
if (refContextDestructuringErrors) { | ||
refContextDestructuringErrors.yield = refContextDestructuringErrors.yield || refDestructuringErrors.yield | ||
refContextDestructuringErrors.await = refContextDestructuringErrors.await || refDestructuringErrors.await | ||
} | ||
this.yieldPos = oldYieldPos || this.yieldPos | ||
this.awaitPos = oldAwaitPos || this.awaitPos | ||
let node = this.startNodeAt(startPos, startLoc) | ||
@@ -277,3 +279,3 @@ node.callee = base | ||
node.tag = base | ||
node.quasi = this.parseTemplate(refContextDestructuringErrors) | ||
node.quasi = this.parseTemplate() | ||
base = this.finishNode(node, "TaggedTemplateExpression") | ||
@@ -338,3 +340,3 @@ } else { | ||
case tt.parenL: | ||
return this.parseParenAndDistinguishExpression(canBeArrow, refDestructuringErrors) | ||
return this.parseParenAndDistinguishExpression(canBeArrow) | ||
@@ -353,12 +355,12 @@ case tt.bracketL: | ||
this.next() | ||
return this.parseFunction(node, false, false, false) | ||
return this.parseFunction(node, false) | ||
case tt._class: | ||
return this.parseClass(this.startNode(), false, refDestructuringErrors) | ||
return this.parseClass(this.startNode(), false) | ||
case tt._new: | ||
return this.parseNew(refDestructuringErrors) | ||
return this.parseNew() | ||
case tt.backQuote: | ||
return this.parseTemplate(refDestructuringErrors) | ||
return this.parseTemplate() | ||
@@ -378,5 +380,5 @@ default: | ||
pp.parseParenExpression = function(refDestructuringErrors) { | ||
pp.parseParenExpression = function() { | ||
this.expect(tt.parenL) | ||
let val = this.parseExpression(false, refDestructuringErrors) | ||
let val = this.parseExpression() | ||
this.expect(tt.parenR) | ||
@@ -386,3 +388,3 @@ return val | ||
pp.parseParenAndDistinguishExpression = function(canBeArrow, refContextDestructuringErrors) { | ||
pp.parseParenAndDistinguishExpression = function(canBeArrow) { | ||
let startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8 | ||
@@ -394,3 +396,5 @@ if (this.options.ecmaVersion >= 6) { | ||
let exprList = [], first = true, lastIsComma = false | ||
let refDestructuringErrors = new DestructuringErrors, spreadStart, innerParenStart | ||
let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart | ||
this.yieldPos = 0 | ||
this.awaitPos = 0 | ||
while (this.type !== tt.parenR) { | ||
@@ -403,3 +407,3 @@ first ? first = false : this.expect(tt.comma) | ||
spreadStart = this.start | ||
exprList.push(this.parseParenItem(this.parseRest(false, refDestructuringErrors))) | ||
exprList.push(this.parseParenItem(this.parseRest())) | ||
if (this.type === tt.comma) this.raise(this.start, "Comma is not permitted after the rest element") | ||
@@ -419,4 +423,6 @@ break | ||
this.checkPatternErrors(refDestructuringErrors, true) | ||
this.checkDefaultValueErrors(refDestructuringErrors, true, true) | ||
this.checkYieldAwaitInDefaultParams() | ||
if (innerParenStart) this.unexpected(innerParenStart) | ||
this.yieldPos = oldYieldPos | ||
this.awaitPos = oldAwaitPos | ||
return this.parseParenArrowList(startPos, startLoc, exprList) | ||
@@ -428,6 +434,4 @@ } | ||
this.checkExpressionErrors(refDestructuringErrors, true) | ||
if (refContextDestructuringErrors) { | ||
refContextDestructuringErrors.yield = refContextDestructuringErrors.yield || refDestructuringErrors.yield | ||
refContextDestructuringErrors.await = refContextDestructuringErrors.await || refDestructuringErrors.await | ||
} | ||
this.yieldPos = oldYieldPos || this.yieldPos | ||
this.awaitPos = oldAwaitPos || this.awaitPos | ||
@@ -442,3 +446,3 @@ if (exprList.length > 1) { | ||
} else { | ||
val = this.parseParenExpression(refContextDestructuringErrors) | ||
val = this.parseParenExpression() | ||
} | ||
@@ -460,3 +464,3 @@ | ||
pp.parseParenArrowList = function(startPos, startLoc, exprList) { | ||
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false) | ||
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList) | ||
} | ||
@@ -472,3 +476,3 @@ | ||
pp.parseNew = function(refDestructuringErrors) { | ||
pp.parseNew = function() { | ||
let node = this.startNode() | ||
@@ -486,4 +490,4 @@ let meta = this.parseIdent(true) | ||
let startPos = this.start, startLoc = this.startLoc | ||
node.callee = this.parseSubscripts(this.parseExprAtom(refDestructuringErrors), startPos, startLoc, true, refDestructuringErrors) | ||
if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors) | ||
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true) | ||
if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false) | ||
else node.arguments = empty | ||
@@ -506,3 +510,3 @@ return this.finishNode(node, "NewExpression") | ||
pp.parseTemplate = function(refDestructuringErrors) { | ||
pp.parseTemplate = function() { | ||
let node = this.startNode() | ||
@@ -515,3 +519,3 @@ this.next() | ||
this.expect(tt.dollarBraceL) | ||
node.expressions.push(this.parseExpression(false, refDestructuringErrors)) | ||
node.expressions.push(this.parseExpression()) | ||
this.expect(tt.braceR) | ||
@@ -547,3 +551,3 @@ node.quasis.push(curElt = this.parseTemplateElement()) | ||
} | ||
this.parsePropertyName(prop, refDestructuringErrors) | ||
this.parsePropertyName(prop) | ||
if (!isPattern && this.options.ecmaVersion >= 8 && !isGenerator && !prop.computed && | ||
@@ -569,3 +573,3 @@ prop.key.type === "Identifier" && prop.key.name === "async" && this.type !== tt.parenL && | ||
if (this.eat(tt.colon)) { | ||
prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc, null, refDestructuringErrors) : this.parseMaybeAssign(false, refDestructuringErrors) | ||
prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors) | ||
prop.kind = "init" | ||
@@ -582,4 +586,4 @@ } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { | ||
prop.kind = prop.key.name | ||
this.parsePropertyName(prop, refDestructuringErrors) | ||
prop.value = this.parseMethod(false, false) | ||
this.parsePropertyName(prop) | ||
prop.value = this.parseMethod(false) | ||
let paramCount = prop.kind === "get" ? 0 : 1 | ||
@@ -604,7 +608,7 @@ if (prop.value.params.length !== paramCount) { | ||
if (isPattern) { | ||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key, refDestructuringErrors) | ||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) | ||
} else if (this.type === tt.eq && refDestructuringErrors) { | ||
if (!refDestructuringErrors.shorthandAssign) | ||
refDestructuringErrors.shorthandAssign = this.start | ||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key, refDestructuringErrors) | ||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) | ||
} else { | ||
@@ -617,7 +621,7 @@ prop.value = prop.key | ||
pp.parsePropertyName = function(prop, refDestructuringErrors) { | ||
pp.parsePropertyName = function(prop) { | ||
if (this.options.ecmaVersion >= 6) { | ||
if (this.eat(tt.bracketL)) { | ||
prop.computed = true | ||
prop.key = this.parseMaybeAssign(false, refDestructuringErrors) | ||
prop.key = this.parseMaybeAssign() | ||
this.expect(tt.bracketR) | ||
@@ -629,3 +633,3 @@ return prop.key | ||
} | ||
return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom(refDestructuringErrors) : this.parseIdent(true) | ||
return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true) | ||
} | ||
@@ -648,3 +652,4 @@ | ||
pp.parseMethod = function(isGenerator, isAsync) { | ||
let node = this.startNode(), refDestructuringErrors = new DestructuringErrors, oldInGen = this.inGenerator, oldInAsync = this.inAsync | ||
let node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos | ||
this.initFunction(node) | ||
@@ -655,10 +660,17 @@ if (this.options.ecmaVersion >= 6) | ||
node.async = !!isAsync | ||
this.inGenerator = node.generator | ||
this.inAsync = node.async | ||
this.yieldPos = 0 | ||
this.awaitPos = 0 | ||
this.expect(tt.parenL) | ||
node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, false, refDestructuringErrors) | ||
this.checkDefaultValueErrors(refDestructuringErrors, false, true) | ||
node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8) | ||
this.checkYieldAwaitInDefaultParams() | ||
this.parseFunctionBody(node, false) | ||
this.inGenerator = oldInGen | ||
this.inAsync = oldInAsync | ||
this.yieldPos = oldYieldPos | ||
this.awaitPos = oldAwaitPos | ||
return this.finishNode(node, "FunctionExpression") | ||
@@ -670,12 +682,20 @@ } | ||
pp.parseArrowExpression = function(node, params, isAsync) { | ||
let oldInGen = this.inGenerator, oldInAsync = this.inAsync | ||
let oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos | ||
this.initFunction(node) | ||
if (this.options.ecmaVersion >= 8) | ||
node.async = !!isAsync | ||
this.inGenerator = false | ||
this.inAsync = node.async | ||
this.yieldPos = 0 | ||
this.awaitPos = 0 | ||
node.params = this.toAssignableList(params, true) | ||
this.parseFunctionBody(node, true) | ||
this.inGenerator = oldInGen | ||
this.inAsync = oldInAsync | ||
this.yieldPos = oldYieldPos | ||
this.awaitPos = oldAwaitPos | ||
return this.finishNode(node, "ArrowFunctionExpression") | ||
@@ -792,5 +812,6 @@ } | ||
pp.parseYield = function(refDestructuringErrors) { | ||
pp.parseYield = function() { | ||
if (!this.yieldPos) this.yieldPos = this.start | ||
let node = this.startNode() | ||
if (refDestructuringErrors) refDestructuringErrors.yield = this.start | ||
this.next() | ||
@@ -802,3 +823,3 @@ if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) { | ||
node.delegate = this.eat(tt.star) | ||
node.argument = this.parseMaybeAssign(false, refDestructuringErrors) | ||
node.argument = this.parseMaybeAssign() | ||
} | ||
@@ -808,8 +829,9 @@ return this.finishNode(node, "YieldExpression") | ||
pp.parseAwait = function(refDestructuringErrors) { | ||
pp.parseAwait = function() { | ||
if (!this.awaitPos) this.awaitPos = this.start | ||
let node = this.startNode() | ||
if (refDestructuringErrors) refDestructuringErrors.await = this.start | ||
this.next() | ||
node.argument = this.parseMaybeUnary(refDestructuringErrors, true) | ||
node.argument = this.parseMaybeUnary(null, true) | ||
return this.finishNode(node, "AwaitExpression") | ||
} |
@@ -39,3 +39,3 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript. | ||
export const version = "4.0.1" | ||
export const version = "4.0.2" | ||
@@ -42,0 +42,0 @@ // The main exported interface (under `self.acorn` when in the |
@@ -13,3 +13,3 @@ import {types as tt} from "./tokentype" | ||
switch (node.type) { | ||
case "Identifier": | ||
case "Identifier": | ||
if (this.inAsync && node.name === "await") | ||
@@ -101,3 +101,3 @@ this.raise(node.start, "Can not use 'await' as identifier inside an async function") | ||
pp.parseRest = function(allowNonIdent, refDestructuringErrors) { | ||
pp.parseRest = function(allowNonIdent) { | ||
let node = this.startNode() | ||
@@ -108,3 +108,3 @@ this.next() | ||
if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected() | ||
else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom(refDestructuringErrors) : this.unexpected() | ||
else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected() | ||
@@ -116,3 +116,3 @@ return this.finishNode(node, "RestElement") | ||
pp.parseBindingAtom = function(refDestructuringErrors) { | ||
pp.parseBindingAtom = function() { | ||
if (this.options.ecmaVersion < 6) return this.parseIdent() | ||
@@ -126,7 +126,7 @@ switch (this.type) { | ||
this.next() | ||
node.elements = this.parseBindingList(tt.bracketR, true, true, false, refDestructuringErrors) | ||
node.elements = this.parseBindingList(tt.bracketR, true, true) | ||
return this.finishNode(node, "ArrayPattern") | ||
case tt.braceL: | ||
return this.parseObj(true, refDestructuringErrors) | ||
return this.parseObj(true) | ||
@@ -138,3 +138,3 @@ default: | ||
pp.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent, refDestructuringErrors) { | ||
pp.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) { | ||
let elts = [], first = true | ||
@@ -149,3 +149,3 @@ while (!this.eat(close)) { | ||
} else if (this.type === tt.ellipsis) { | ||
let rest = this.parseRest(allowNonIdent, refDestructuringErrors) | ||
let rest = this.parseRest(allowNonIdent) | ||
this.parseBindingListItem(rest) | ||
@@ -157,3 +157,3 @@ elts.push(rest) | ||
} else { | ||
let elem = this.parseMaybeDefault(this.start, this.startLoc, null, refDestructuringErrors) | ||
let elem = this.parseMaybeDefault(this.start, this.startLoc) | ||
this.parseBindingListItem(elem) | ||
@@ -172,8 +172,8 @@ elts.push(elem) | ||
pp.parseMaybeDefault = function(startPos, startLoc, left, refDestructuringErrors) { | ||
left = left || this.parseBindingAtom(refDestructuringErrors) | ||
pp.parseMaybeDefault = function(startPos, startLoc, left) { | ||
left = left || this.parseBindingAtom() | ||
if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left | ||
let node = this.startNodeAt(startPos, startLoc) | ||
node.left = left | ||
node.right = this.parseMaybeAssign(false, refDestructuringErrors) | ||
node.right = this.parseMaybeAssign() | ||
return this.finishNode(node, "AssignmentPattern") | ||
@@ -180,0 +180,0 @@ } |
@@ -9,3 +9,3 @@ import {has, isArray} from "./util" | ||
// `ecmaVersion` indicates the ECMAScript version to parse. Must | ||
// be either 3, 5, 6 (2015), or 7 (2016). This influences support | ||
// be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support | ||
// for strict mode, the set of reserved words, and support for | ||
@@ -12,0 +12,0 @@ // new syntax features. The default is 7. |
@@ -97,4 +97,2 @@ import {types as tt} from "./tokentype" | ||
this.trailingComma = 0 | ||
this.yield = 0 | ||
this.await = 0 | ||
} | ||
@@ -115,8 +113,7 @@ } | ||
pp.checkDefaultValueErrors = function(refDestructuringErrors, isArrow, andThrow) { | ||
let yieldPos = (isArrow || this.inGenerator) && refDestructuringErrors && refDestructuringErrors.yield | ||
let awaitPos = (isArrow || this.inAsync) && refDestructuringErrors && refDestructuringErrors.await | ||
if (!andThrow) return !!(yieldPos || awaitPos) | ||
if (yieldPos && (!awaitPos || yieldPos < awaitPos)) this.raise(yieldPos, "Yield expression cannot be a default value") | ||
if (awaitPos) this.raise(awaitPos, "Await expression cannot be a default value") | ||
pp.checkYieldAwaitInDefaultParams = function() { | ||
if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) | ||
this.raise(this.yieldPos, "Yield expression cannot be a default value") | ||
if (this.awaitPos) | ||
this.raise(this.awaitPos, "Await expression cannot be a default value") | ||
} |
@@ -75,2 +75,4 @@ import {reservedWords, keywords} from "./identifier" | ||
this.inFunction = this.inGenerator = this.inAsync = false | ||
// Positions to delayed-check that yield/await does not exist in default parameters. | ||
this.yieldPos = this.awaitPos = 0 | ||
// Labels in scope. | ||
@@ -77,0 +79,0 @@ this.labels = [] |
@@ -453,7 +453,12 @@ import {types as tt} from "./tokentype" | ||
node.async = !!isAsync | ||
if (isStatement) | ||
node.id = this.parseIdent() | ||
var oldInGen = this.inGenerator, oldInAsync = this.inAsync | ||
let oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos | ||
this.inGenerator = node.generator | ||
this.inAsync = node.async | ||
this.yieldPos = 0 | ||
this.awaitPos = 0 | ||
if (!isStatement && this.type === tt.name) | ||
@@ -463,4 +468,7 @@ node.id = this.parseIdent() | ||
this.parseFunctionBody(node, allowExpressionBody) | ||
this.inGenerator = oldInGen | ||
this.inAsync = oldInAsync | ||
this.yieldPos = oldYieldPos | ||
this.awaitPos = oldAwaitPos | ||
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") | ||
@@ -471,6 +479,4 @@ } | ||
this.expect(tt.parenL) | ||
let refDestructuringErrors = new DestructuringErrors | ||
node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true, refDestructuringErrors) | ||
this.checkDefaultValueErrors(refDestructuringErrors, false, true) | ||
node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true) | ||
this.checkYieldAwaitInDefaultParams() | ||
} | ||
@@ -481,6 +487,6 @@ | ||
pp.parseClass = function(node, isStatement, refDestructuringErrors) { | ||
pp.parseClass = function(node, isStatement) { | ||
this.next() | ||
this.parseClassId(node, isStatement) | ||
this.parseClassSuper(node, refDestructuringErrors) | ||
this.parseClassSuper(node) | ||
let classBody = this.startNode() | ||
@@ -496,3 +502,3 @@ let hadConstructor = false | ||
let isMaybeStatic = this.type === tt.name && this.value === "static" | ||
this.parsePropertyName(method, refDestructuringErrors) | ||
this.parsePropertyName(method) | ||
method.static = isMaybeStatic && this.type !== tt.parenL | ||
@@ -502,3 +508,3 @@ if (method.static) { | ||
isGenerator = this.eat(tt.star) | ||
this.parsePropertyName(method, refDestructuringErrors) | ||
this.parsePropertyName(method) | ||
} | ||
@@ -509,3 +515,3 @@ if (this.options.ecmaVersion >= 8 && !isGenerator && !method.computed && | ||
isAsync = true | ||
this.parsePropertyName(method, refDestructuringErrors) | ||
this.parsePropertyName(method) | ||
} | ||
@@ -519,3 +525,3 @@ method.kind = "method" | ||
method.kind = key.name | ||
key = this.parsePropertyName(method, refDestructuringErrors) | ||
key = this.parsePropertyName(method) | ||
} | ||
@@ -560,4 +566,4 @@ if (!method.static && (key.type === "Identifier" && key.name === "constructor" || | ||
pp.parseClassSuper = function(node, refDestructuringErrors) { | ||
node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts(refDestructuringErrors) : null | ||
pp.parseClassSuper = function(node) { | ||
node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null | ||
} | ||
@@ -564,0 +570,0 @@ |
@@ -494,4 +494,5 @@ import {isIdentifierStart, isIdentifierChar} from "./identifier" | ||
if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number") | ||
if (octal && this.pos == start + 1) octal = false | ||
let next = this.input.charCodeAt(this.pos) | ||
if (next === 46) { // '.' | ||
if (next === 46 && !octal) { // '.' | ||
++this.pos | ||
@@ -502,3 +503,3 @@ this.readInt(10) | ||
} | ||
if (next === 69 || next === 101) { // 'eE' | ||
if ((next === 69 || next === 101) && !octal) { // 'eE' | ||
next = this.input.charCodeAt(++this.pos) | ||
@@ -505,0 +506,0 @@ if (next === 43 || next === 45) ++this.pos // '+-' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
13511
576287