Socket
Socket
Sign inDemoInstall

acorn

Package Overview
Dependencies
Maintainers
2
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn - npm Package Compare versions

Comparing version 4.0.8 to 4.0.9

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## 4.0.9 (2017-02-06)
### Bug fixes
Fix incorrect error raised for parenthesized simple assignment
targets, so that `(x) = 1` parses again.
## 4.0.8 (2017-02-03)

@@ -2,0 +9,0 @@

2

package.json

@@ -7,3 +7,3 @@ {

"jsnext:main": "dist/acorn.es.js",
"version": "4.0.8",
"version": "4.0.9",
"engines": {

@@ -10,0 +10,0 @@ "node": ">=0.4.0"

@@ -96,7 +96,11 @@ // A recursive descent parser operates by defining functions for all

let ownDestructuringErrors = false
if (!refDestructuringErrors) {
let ownDestructuringErrors = false, oldParenAssign = -1
if (refDestructuringErrors) {
oldParenAssign = refDestructuringErrors.parenthesizedAssign
refDestructuringErrors.parenthesizedAssign = -1
} else {
refDestructuringErrors = new DestructuringErrors
ownDestructuringErrors = true
}
let startPos = this.start, startLoc = this.startLoc

@@ -108,10 +112,3 @@ if (this.type == tt.parenL || this.type == tt.name)

if (this.type.isAssign) {
if (left.type != "MemberExpression") {
// FIXME this isn't correct, but is a workaround for the problem
// of refDestructuringErrors being shared between the potential
// arrow function arglist and an assignment inside that list.
// See #502
if (refDestructuringErrors.parenthesized < startPos) refDestructuringErrors.parenthesized = -1
this.checkPatternErrors(refDestructuringErrors)
}
this.checkPatternErrors(refDestructuringErrors, true)
if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)

@@ -129,2 +126,3 @@ let node = this.startNodeAt(startPos, startLoc)

}
if (oldParenAssign > -1) refDestructuringErrors.parenthesizedAssign = oldParenAssign
return left

@@ -236,3 +234,8 @@ }

if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr
return this.parseSubscripts(expr, startPos, startLoc)
let result = this.parseSubscripts(expr, startPos, startLoc)
if (refDestructuringErrors && result.type === "MemberExpression") {
if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1
if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1
}
return result
}

@@ -243,16 +246,10 @@

this.lastTokEnd == base.end && !this.canInsertSemicolon()
for (;;) {
if (this.eat(tt.dot)) {
for (let computed;;) {
if ((computed = this.eat(tt.bracketL)) || this.eat(tt.dot)) {
let node = this.startNodeAt(startPos, startLoc)
node.object = base
node.property = this.parseIdent(true)
node.computed = false
node.property = computed ? this.parseExpression() : this.parseIdent(true)
node.computed = !!computed
if (computed) this.expect(tt.bracketR)
base = this.finishNode(node, "MemberExpression")
} else if (this.eat(tt.bracketL)) {
let node = this.startNodeAt(startPos, startLoc)
node.object = base
node.property = this.parseExpression()
node.computed = true
this.expect(tt.bracketR)
base = this.finishNode(node, "MemberExpression")
} else if (!noCalls && this.eat(tt.parenL)) {

@@ -264,3 +261,3 @@ let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos

if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
this.checkPatternErrors(refDestructuringErrors)
this.checkPatternErrors(refDestructuringErrors, false)
this.checkYieldAwaitInDefaultParams()

@@ -341,5 +338,10 @@ this.yieldPos = oldYieldPos

case tt.parenL:
if (refDestructuringErrors && refDestructuringErrors.parenthesized < 0)
refDestructuringErrors.parenthesized = this.start
return this.parseParenAndDistinguishExpression(canBeArrow)
let start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow)
if (refDestructuringErrors) {
if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
refDestructuringErrors.parenthesizedAssign = start
if (refDestructuringErrors.parenthesizedBind < 0)
refDestructuringErrors.parenthesizedBind = start
}
return expr

@@ -420,3 +422,3 @@ case tt.bracketL:

if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
this.checkPatternErrors(refDestructuringErrors)
this.checkPatternErrors(refDestructuringErrors, false)
this.checkYieldAwaitInDefaultParams()

@@ -423,0 +425,0 @@ if (innerParenStart) this.unexpected(innerParenStart)

@@ -39,3 +39,3 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript.

export const version = "4.0.8"
export const version = "4.0.9"

@@ -42,0 +42,0 @@ // The main exported interface (under `self.acorn` when in the

@@ -99,10 +99,11 @@ import {types as tt} from "./tokentype"

constructor() {
this.shorthandAssign = this.trailingComma = this.parenthesized = -1
this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = -1
}
}
pp.checkPatternErrors = function(refDestructuringErrors) {
let trailing = refDestructuringErrors ? refDestructuringErrors.trailingComma : -1
let parens = refDestructuringErrors ? refDestructuringErrors.parenthesized : -1
if (trailing > -1) this.raiseRecoverable(trailing, "Comma is not permitted after the rest element")
pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
if (!refDestructuringErrors) return
if (refDestructuringErrors.trailingComma > -1)
this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element")
let parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind
if (parens > -1) this.raiseRecoverable(parens, "Parenthesized pattern")

@@ -123,1 +124,8 @@ }

}
pp.isSimpleAssignTarget = function(expr) {
return expr.type === "Identifier" ||
(expr.type === "MemberExpression" && (expr.object.type === "MemberExpression" ||
expr.object.type === "CallExpression" ||
expr.object.type === "Super"))
}

@@ -204,3 +204,3 @@ import {types as tt} from "./tokentype"

this.checkLVal(init)
if (init.type != "MemberExpression") this.checkPatternErrors(refDestructuringErrors)
this.checkPatternErrors(refDestructuringErrors, true)
return this.parseForIn(node, init)

@@ -207,0 +207,0 @@ } else {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc