From 5c2b200beaeb1f5197b6a8b85d543c5ae31d8b33 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Wed, 12 Jul 2023 14:07:16 +0100 Subject: [PATCH] deps: update acorn to 8.10.0 PR-URL: https://github.com/nodejs/node/pull/48713 Reviewed-By: Luigi Pinca Reviewed-By: Benjamin Gruenbaum Reviewed-By: Mohammed Keyvanzadeh --- deps/acorn/acorn/CHANGELOG.md | 6 ++++++ deps/acorn/acorn/README.md | 4 ++++ deps/acorn/acorn/dist/acorn.d.ts | 2 +- deps/acorn/acorn/dist/acorn.js | 19 +++++++++++++------ deps/acorn/acorn/dist/acorn.mjs | 19 +++++++++++++------ deps/acorn/acorn/package.json | 2 +- src/acorn_version.h | 2 +- 7 files changed, 39 insertions(+), 15 deletions(-) diff --git a/deps/acorn/acorn/CHANGELOG.md b/deps/acorn/acorn/CHANGELOG.md index 6a0883a69c5790..12464cfdbeefdd 100644 --- a/deps/acorn/acorn/CHANGELOG.md +++ b/deps/acorn/acorn/CHANGELOG.md @@ -1,3 +1,9 @@ +## 8.10.0 (2023-07-05) + +### New features + +Add a `checkPrivateFields` option that disables strict checking of private property use. + ## 8.9.0 (2023-06-16) ### Bug fixes diff --git a/deps/acorn/acorn/README.md b/deps/acorn/acorn/README.md index bd267706f3fcea..b62d02bde1fbb0 100644 --- a/deps/acorn/acorn/README.md +++ b/deps/acorn/acorn/README.md @@ -109,6 +109,10 @@ required): characters `#!` (as in a shellscript), the first line will be treated as a comment. Defaults to true when `ecmaVersion` >= 2023. +- **checkPrivateFields**: By default, the parser will verify that + private properties are only used in places where they are valid and + have been declared. Set this to false to turn such checks off. + - **locations**: When `true`, each node has a `loc` object attached with `start` and `end` subobjects, each of which contains the one-based line and zero-based column numbers in `{line, column}` diff --git a/deps/acorn/acorn/dist/acorn.d.ts b/deps/acorn/acorn/dist/acorn.d.ts index 355d4e2ce76ea3..5b26741473db1a 100644 --- a/deps/acorn/acorn/dist/acorn.d.ts +++ b/deps/acorn/acorn/dist/acorn.d.ts @@ -11,7 +11,7 @@ declare namespace acorn { [Symbol.iterator](): Iterator } - type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 'latest' + type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 'latest' interface Options { ecmaVersion: ecmaVersion diff --git a/deps/acorn/acorn/dist/acorn.js b/deps/acorn/acorn/dist/acorn.js index 300c7430bcba6d..62e1aa63d0974f 100644 --- a/deps/acorn/acorn/dist/acorn.js +++ b/deps/acorn/acorn/dist/acorn.js @@ -372,6 +372,10 @@ // allowed and treated as a line comment. Enabled by default when // `ecmaVersion` >= 2023. allowHashBang: false, + // By default, the parser will verify that private properties are + // only used in places where they are valid and have been declared. + // Set this to false to turn such checks off. + checkPrivateFields: true, // When `locations` is on, `loc` properties holding objects with // `start` and `end` properties in `{line, column}` form (with // line being 1-based and column 0-based) will be attached to the @@ -1600,6 +1604,7 @@ var ref = this.privateNameStack.pop(); var declared = ref.declared; var used = ref.used; + if (!this.options.checkPrivateFields) { return } var len = this.privateNameStack.length; var parent = len === 0 ? null : this.privateNameStack[len - 1]; for (var i = 0; i < used.length; ++i) { @@ -2661,7 +2666,7 @@ else { sawUnary = true; } expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); } else if (!sawUnary && this.type === types$1.privateId) { - if (forInit || this.privateNameStack.length === 0) { this.unexpected(); } + if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } expr = this.parsePrivateIdent(); // only could be private fields in 'in', such as #x in obj if (this.type !== types$1._in) { this.unexpected(); } @@ -3504,10 +3509,12 @@ this.finishNode(node, "PrivateIdentifier"); // For validating existence - if (this.privateNameStack.length === 0) { - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); - } else { - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); + if (this.options.checkPrivateFields) { + if (this.privateNameStack.length === 0) { + this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); + } else { + this.privateNameStack[this.privateNameStack.length - 1].used.push(node); + } } return node @@ -5907,7 +5914,7 @@ // [walk]: util/walk.js - var version = "8.9.0"; + var version = "8.10.0"; Parser.acorn = { Parser: Parser, diff --git a/deps/acorn/acorn/dist/acorn.mjs b/deps/acorn/acorn/dist/acorn.mjs index 6f30642569f64b..119eff98d4ded6 100644 --- a/deps/acorn/acorn/dist/acorn.mjs +++ b/deps/acorn/acorn/dist/acorn.mjs @@ -366,6 +366,10 @@ var defaultOptions = { // allowed and treated as a line comment. Enabled by default when // `ecmaVersion` >= 2023. allowHashBang: false, + // By default, the parser will verify that private properties are + // only used in places where they are valid and have been declared. + // Set this to false to turn such checks off. + checkPrivateFields: true, // When `locations` is on, `loc` properties holding objects with // `start` and `end` properties in `{line, column}` form (with // line being 1-based and column 0-based) will be attached to the @@ -1594,6 +1598,7 @@ pp$8.exitClassBody = function() { var ref = this.privateNameStack.pop(); var declared = ref.declared; var used = ref.used; + if (!this.options.checkPrivateFields) { return } var len = this.privateNameStack.length; var parent = len === 0 ? null : this.privateNameStack[len - 1]; for (var i = 0; i < used.length; ++i) { @@ -2655,7 +2660,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni else { sawUnary = true; } expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); } else if (!sawUnary && this.type === types$1.privateId) { - if (forInit || this.privateNameStack.length === 0) { this.unexpected(); } + if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } expr = this.parsePrivateIdent(); // only could be private fields in 'in', such as #x in obj if (this.type !== types$1._in) { this.unexpected(); } @@ -3498,10 +3503,12 @@ pp$5.parsePrivateIdent = function() { this.finishNode(node, "PrivateIdentifier"); // For validating existence - if (this.privateNameStack.length === 0) { - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); - } else { - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); + if (this.options.checkPrivateFields) { + if (this.privateNameStack.length === 0) { + this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); + } else { + this.privateNameStack[this.privateNameStack.length - 1].used.push(node); + } } return node @@ -5901,7 +5908,7 @@ pp.readWord = function() { // [walk]: util/walk.js -var version = "8.9.0"; +var version = "8.10.0"; Parser.acorn = { Parser: Parser, diff --git a/deps/acorn/acorn/package.json b/deps/acorn/acorn/package.json index 3ff4041a85f497..4243aa3542deb3 100644 --- a/deps/acorn/acorn/package.json +++ b/deps/acorn/acorn/package.json @@ -16,7 +16,7 @@ ], "./package.json": "./package.json" }, - "version": "8.9.0", + "version": "8.10.0", "engines": { "node": ">=0.4.0" }, diff --git a/src/acorn_version.h b/src/acorn_version.h index 05c9f3440a19c6..8c71b2ece5aa80 100644 --- a/src/acorn_version.h +++ b/src/acorn_version.h @@ -2,5 +2,5 @@ // Refer to tools/update-acorn.sh #ifndef SRC_ACORN_VERSION_H_ #define SRC_ACORN_VERSION_H_ -#define ACORN_VERSION "8.9.0" +#define ACORN_VERSION "8.10.0" #endif // SRC_ACORN_VERSION_H_