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.2 to 4.0.3

11

CHANGELOG.md

@@ -0,1 +1,12 @@

## 4.0.3 (2016-08-16)
### Bug fixes
Allow regular function declarations inside single-statement `if`
branches in loose mode. Forbid them entirely in strict mode.
Properly parse properties named `async` in ES2017 mode.
Fix bug where reserved words were broken in ES2017 mode.
## 4.0.2 (2016-08-11)

@@ -2,0 +13,0 @@

2

dist/acorn_loose.es.js

@@ -1120,3 +1120,3 @@ import { defaultOptions, addLooseExports, SourceLocation, tokTypes, tokenizer, Node, lineBreak, isNewLine, getLineInfo, Token, lineBreakG } from './acorn.js';

prop.key.type === "Identifier" && prop.key.name === "async" && this$1.tok.type !== tokTypes.parenL &&
!this$1.canInsertSemicolon()) {
this$1.tok.type !== tokTypes.colon && !this$1.canInsertSemicolon()) {
this$1.parsePropertyName(prop)

@@ -1123,0 +1123,0 @@ isAsync = true

@@ -1124,3 +1124,3 @@ (function (global, factory) {

prop.key.type === "Identifier" && prop.key.name === "async" && this$1.tok.type !== __acorn_js.tokTypes.parenL &&
!this$1.canInsertSemicolon()) {
this$1.tok.type !== __acorn_js.tokTypes.colon && !this$1.canInsertSemicolon()) {
this$1.parsePropertyName(prop)

@@ -1127,0 +1127,0 @@ isAsync = true

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

"jsnext:main": "dist/acorn.es.js",
"version": "4.0.2",
"version": "4.0.3",
"engines": {

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

@@ -527,3 +527,3 @@ // A recursive descent parser operates by defining functions for all

prop.key.type === "Identifier" && prop.key.name === "async" && this.type !== tt.parenL &&
!this.canInsertSemicolon()) {
this.type !== tt.colon && !this.canInsertSemicolon()) {
isAsync = true

@@ -530,0 +530,0 @@ this.parsePropertyName(prop, refDestructuringErrors)

@@ -7,3 +7,2 @@ // Reserved word lists for various dialects of the language

6: "enum",
7: "enum",
strict: "implements interface let package private protected public static yield",

@@ -10,0 +9,0 @@ strictBind: "eval arguments"

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

export const version = "4.0.2"
export const version = "4.0.3"

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

@@ -371,3 +371,3 @@ import {LooseParser} from "./state"

prop.key.type === "Identifier" && prop.key.name === "async" && this.tok.type !== tt.parenL &&
!this.canInsertSemicolon()) {
this.tok.type !== tt.colon && !this.canInsertSemicolon()) {
this.parsePropertyName(prop)

@@ -374,0 +374,0 @@ isAsync = true

@@ -18,4 +18,8 @@ import {reservedWords, keywords} from "./identifier"

this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
let reserved = options.allowReserved ? "" :
reservedWords[options.ecmaVersion] + (options.sourceType == "module" ? " await" : "")
let reserved = ""
if (!options.allowReserved) {
for (let v = options.ecmaVersion;; v--)
if (reserved = reservedWords[v]) break
if (options.sourceType == "module") reserved += " await"
}
this.reservedWords = keywordRegexp(reserved)

@@ -22,0 +26,0 @@ let reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict

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

case tt._function:
if (!declaration && this.options.ecmaVersion >= 6) break
if (!declaration && this.options.ecmaVersion >= 6) this.unexpected()
return this.parseFunctionStatement(node, false)

@@ -118,18 +118,19 @@ case tt._class:

return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports)
}
if (this.isAsyncFunction() && declaration) {
this.next()
return this.parseFunctionStatement(node, true)
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
// simply start parsing an expression, and afterwards, if the
// next token is a colon and the expression was a simple
// Identifier node, we switch to interpreting it as a label.
default:
if (this.isAsyncFunction() && declaration) {
this.next()
return this.parseFunctionStatement(node, true)
}
let maybeName = this.value, expr = this.parseExpression()
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon))
return this.parseLabeledStatement(node, maybeName, expr)
else return this.parseExpressionStatement(node, expr)
}
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
// simply start parsing an expression, and afterwards, if the
// next token is a colon and the expression was a simple
// Identifier node, we switch to interpreting it as a label.
let maybeName = this.value, expr = this.parseExpression()
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon))
return this.parseLabeledStatement(node, maybeName, expr)
else return this.parseExpressionStatement(node, expr)
}

@@ -222,7 +223,12 @@

pp.isFunction = function() {
return this.type === tt._function || this.isAsyncFunction()
}
pp.parseIfStatement = function(node) {
this.next()
node.test = this.parseParenExpression()
node.consequent = this.parseStatement(false)
node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null
// allow function declarations in branches, but only in non-strict mode
node.consequent = this.parseStatement(!this.strict && this.isFunction())
node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null
return this.finishNode(node, "IfStatement")

@@ -731,3 +737,3 @@ }

if (this.isKeyword(node.local.name)) this.unexpected(node.local.start)
if (this.reservedWordsStrict.test(node.local.name)) this.raise(node.local.start, "The keyword '" + node.local.name + "' is reserved")
if (this.reservedWordsStrict.test(node.local.name)) this.raiseRecoverable(node.local.start, "The keyword '" + node.local.name + "' is reserved")
}

@@ -734,0 +740,0 @@ this.checkLVal(node.local, true)

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