Skip to content

Commit 38aa9d6

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update acorn to 8.12.1
PR-URL: #53465 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 0309b05 commit 38aa9d6

File tree

8 files changed

+239
-86
lines changed

8 files changed

+239
-86
lines changed

deps/acorn/acorn/CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
## 8.12.1 (2024-07-03)
2+
3+
### Bug fixes
4+
5+
Fix a regression that caused Acorn to no longer run on Node versions <8.10.
6+
7+
## 8.12.0 (2024-06-14)
8+
9+
### New features
10+
11+
Support ES2025 duplicate capture group names in regular expressions.
12+
13+
### Bug fixes
14+
15+
Include `VariableDeclarator` in the `AnyNode` type so that walker objects can refer to it without getting a type error.
16+
17+
Properly raise a parse error for invalid `for`/`of` statements using `async` as binding name.
18+
19+
Properly recognize \"use strict\" when preceded by a string with an escaped newline.
20+
21+
Mark the `Parser` constructor as protected, not private, so plugins can extend it without type errors.
22+
23+
Fix a bug where some invalid `delete` expressions were let through when the operand was parenthesized and `preserveParens` was enabled.
24+
25+
Properly normalize line endings in raw strings of invalid template tokens.
26+
27+
Properly track line numbers for escaped newlines in strings.
28+
29+
Fix a bug that broke line number accounting after a template literal with invalid escape sequences.
30+
131
## 8.11.3 (2023-12-29)
232

333
### Bug fixes

deps/acorn/acorn/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ Options are provided by in a second argument, which should be an
5050
object containing any of these fields (only `ecmaVersion` is
5151
required):
5252

53-
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
54-
either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019),
55-
11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` (the
56-
latest the library supports). This influences support for strict
57-
mode, the set of reserved words, and support for new syntax
58-
features.
53+
- **ecmaVersion**: Indicates the ECMAScript version to parse. Can be a
54+
number, either in year (`2022`) or plain version number (`6`) form,
55+
or `"latest"` (the latest the library supports). This influences
56+
support for strict mode, the set of reserved words, and support for
57+
new syntax features.
5958

6059
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
6160
implemented by Acorn. Other proposed new features must be

deps/acorn/acorn/dist/acorn.d.mts

+8-9
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export type ModuleDeclaration =
562562
| ExportDefaultDeclaration
563563
| ExportAllDeclaration
564564

565-
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock
565+
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
566566

567567
export function parse(input: string, options: Options): Program
568568

@@ -573,16 +573,15 @@ export function tokenizer(input: string, options: Options): {
573573
[Symbol.iterator](): Iterator<Token>
574574
}
575575

576-
export 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"
576+
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
577577

578578
export interface Options {
579579
/**
580-
* `ecmaVersion` indicates the ECMAScript version to parse. Must be
581-
* either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
582-
* (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
583-
* (the latest version the library supports). This influences
584-
* support for strict mode, the set of reserved words, and support
585-
* for new syntax features.
580+
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
581+
* number, either in year (`2022`) or plain version number (`6`) form,
582+
* or `"latest"` (the latest the library supports). This influences
583+
* support for strict mode, the set of reserved words, and support for
584+
* new syntax features.
586585
*/
587586
ecmaVersion: ecmaVersion
588587

@@ -733,7 +732,7 @@ export class Parser {
733732
options: Options
734733
input: string
735734

736-
private constructor(options: Options, input: string, startPos?: number)
735+
protected constructor(options: Options, input: string, startPos?: number)
737736
parse(): Program
738737

739738
static parse(input: string, options: Options): Program

deps/acorn/acorn/dist/acorn.d.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export type ModuleDeclaration =
562562
| ExportDefaultDeclaration
563563
| ExportAllDeclaration
564564

565-
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock
565+
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
566566

567567
export function parse(input: string, options: Options): Program
568568

@@ -573,16 +573,15 @@ export function tokenizer(input: string, options: Options): {
573573
[Symbol.iterator](): Iterator<Token>
574574
}
575575

576-
export 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"
576+
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
577577

578578
export interface Options {
579579
/**
580-
* `ecmaVersion` indicates the ECMAScript version to parse. Must be
581-
* either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
582-
* (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
583-
* (the latest version the library supports). This influences
584-
* support for strict mode, the set of reserved words, and support
585-
* for new syntax features.
580+
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
581+
* number, either in year (`2022`) or plain version number (`6`) form,
582+
* or `"latest"` (the latest the library supports). This influences
583+
* support for strict mode, the set of reserved words, and support for
584+
* new syntax features.
586585
*/
587586
ecmaVersion: ecmaVersion
588587

@@ -733,7 +732,7 @@ export class Parser {
733732
options: Options
734733
input: string
735734

736-
private constructor(options: Options, input: string, startPos?: number)
735+
protected constructor(options: Options, input: string, startPos?: number)
737736
parse(): Program
738737

739738
static parse(input: string, options: Options): Program

deps/acorn/acorn/dist/acorn.js

+92-29
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@
667667

668668
// ## Parser utilities
669669

670-
var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
670+
var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
671671
pp$9.strictDirective = function(start) {
672672
if (this.options.ecmaVersion < 5) { return false }
673673
for (;;) {
@@ -853,7 +853,7 @@
853853
// Statement) is allowed here. If context is not empty then only a Statement
854854
// is allowed. However, `let [` is an explicit negative lookahead for
855855
// ExpressionStatement, so special-case it first.
856-
if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'
856+
if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
857857
if (context) { return false }
858858

859859
if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
@@ -1046,13 +1046,19 @@
10461046
return this.parseFor(node, init$1)
10471047
}
10481048
var startsWithLet = this.isContextual("let"), isForOf = false;
1049+
var containsEsc = this.containsEsc;
10491050
var refDestructuringErrors = new DestructuringErrors;
1050-
var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
1051+
var initPos = this.start;
1052+
var init = awaitAt > -1
1053+
? this.parseExprSubscripts(refDestructuringErrors, "await")
1054+
: this.parseExpression(true, refDestructuringErrors);
10511055
if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1052-
if (this.options.ecmaVersion >= 9) {
1053-
if (this.type === types$1._in) {
1054-
if (awaitAt > -1) { this.unexpected(awaitAt); }
1055-
} else { node.await = awaitAt > -1; }
1056+
if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt)
1057+
if (this.type === types$1._in) { this.unexpected(awaitAt); }
1058+
node.await = true;
1059+
} else if (isForOf && this.options.ecmaVersion >= 8) {
1060+
if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); }
1061+
else if (this.options.ecmaVersion >= 9) { node.await = false; }
10561062
}
10571063
if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
10581064
this.toAssignable(init, false, refDestructuringErrors);
@@ -2665,8 +2671,7 @@
26652671
node.argument = this.parseMaybeUnary(null, true, update, forInit);
26662672
this.checkExpressionErrors(refDestructuringErrors, true);
26672673
if (update) { this.checkLValSimple(node.argument); }
2668-
else if (this.strict && node.operator === "delete" &&
2669-
node.argument.type === "Identifier")
2674+
else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument))
26702675
{ this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
26712676
else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
26722677
{ this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
@@ -2701,10 +2706,18 @@
27012706
}
27022707
};
27032708

2709+
function isLocalVariableAccess(node) {
2710+
return (
2711+
node.type === "Identifier" ||
2712+
node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression)
2713+
)
2714+
}
2715+
27042716
function isPrivateFieldAccess(node) {
27052717
return (
27062718
node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
2707-
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
2719+
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) ||
2720+
node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression)
27082721
)
27092722
}
27102723

@@ -3131,7 +3144,7 @@
31313144
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
31323145
}
31333146
elem.value = {
3134-
raw: this.value,
3147+
raw: this.value.replace(/\r\n?/g, "\n"),
31353148
cooked: null
31363149
};
31373150
} else {
@@ -3806,6 +3819,30 @@
38063819

38073820
var pp$1 = Parser.prototype;
38083821

3822+
// Track disjunction structure to determine whether a duplicate
3823+
// capture group name is allowed because it is in a separate branch.
3824+
var BranchID = function BranchID(parent, base) {
3825+
// Parent disjunction branch
3826+
this.parent = parent;
3827+
// Identifies this set of sibling branches
3828+
this.base = base || this;
3829+
};
3830+
3831+
BranchID.prototype.separatedFrom = function separatedFrom (alt) {
3832+
// A branch is separate from another branch if they or any of
3833+
// their parents are siblings in a given disjunction
3834+
for (var self = this; self; self = self.parent) {
3835+
for (var other = alt; other; other = other.parent) {
3836+
if (self.base === other.base && self !== other) { return true }
3837+
}
3838+
}
3839+
return false
3840+
};
3841+
3842+
BranchID.prototype.sibling = function sibling () {
3843+
return new BranchID(this.parent, this.base)
3844+
};
3845+
38093846
var RegExpValidationState = function RegExpValidationState(parser) {
38103847
this.parser = parser;
38113848
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
@@ -3822,8 +3859,9 @@
38223859
this.lastAssertionIsQuantifiable = false;
38233860
this.numCapturingParens = 0;
38243861
this.maxBackReference = 0;
3825-
this.groupNames = [];
3862+
this.groupNames = Object.create(null);
38263863
this.backReferenceNames = [];
3864+
this.branchID = null;
38273865
};
38283866

38293867
RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
@@ -3955,6 +3993,11 @@
39553993
}
39563994
};
39573995

3996+
function hasProp(obj) {
3997+
for (var _ in obj) { return true }
3998+
return false
3999+
}
4000+
39584001
/**
39594002
* Validate the pattern part of a given RegExpLiteral.
39604003
*
@@ -3969,7 +4012,7 @@
39694012
// |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
39704013
// exception if _P_ did not conform to the grammar, if any elements of _P_
39714014
// were not matched by the parse, or if any Early Error conditions exist.
3972-
if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
4015+
if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) {
39734016
state.switchN = true;
39744017
this.regexp_pattern(state);
39754018
}
@@ -3983,8 +4026,9 @@
39834026
state.lastAssertionIsQuantifiable = false;
39844027
state.numCapturingParens = 0;
39854028
state.maxBackReference = 0;
3986-
state.groupNames.length = 0;
4029+
state.groupNames = Object.create(null);
39874030
state.backReferenceNames.length = 0;
4031+
state.branchID = null;
39884032

39894033
this.regexp_disjunction(state);
39904034

@@ -4003,18 +4047,22 @@
40034047
for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
40044048
var name = list[i];
40054049

4006-
if (state.groupNames.indexOf(name) === -1) {
4050+
if (!state.groupNames[name]) {
40074051
state.raise("Invalid named capture referenced");
40084052
}
40094053
}
40104054
};
40114055

40124056
// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
40134057
pp$1.regexp_disjunction = function(state) {
4058+
var trackDisjunction = this.options.ecmaVersion >= 16;
4059+
if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); }
40144060
this.regexp_alternative(state);
40154061
while (state.eat(0x7C /* | */)) {
4062+
if (trackDisjunction) { state.branchID = state.branchID.sibling(); }
40164063
this.regexp_alternative(state);
40174064
}
4065+
if (trackDisjunction) { state.branchID = state.branchID.parent; }
40184066

40194067
// Make the same message as V8.
40204068
if (this.regexp_eatQuantifier(state, true)) {
@@ -4027,8 +4075,7 @@
40274075

40284076
// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
40294077
pp$1.regexp_alternative = function(state) {
4030-
while (state.pos < state.source.length && this.regexp_eatTerm(state))
4031-
{ }
4078+
while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
40324079
};
40334080

40344081
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
@@ -4266,14 +4313,26 @@
42664313
// `?` GroupName
42674314
pp$1.regexp_groupSpecifier = function(state) {
42684315
if (state.eat(0x3F /* ? */)) {
4269-
if (this.regexp_eatGroupName(state)) {
4270-
if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
4316+
if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); }
4317+
var trackDisjunction = this.options.ecmaVersion >= 16;
4318+
var known = state.groupNames[state.lastStringValue];
4319+
if (known) {
4320+
if (trackDisjunction) {
4321+
for (var i = 0, list = known; i < list.length; i += 1) {
4322+
var altID = list[i];
4323+
4324+
if (!altID.separatedFrom(state.branchID))
4325+
{ state.raise("Duplicate capture group name"); }
4326+
}
4327+
} else {
42714328
state.raise("Duplicate capture group name");
42724329
}
4273-
state.groupNames.push(state.lastStringValue);
4274-
return
42754330
}
4276-
state.raise("Invalid group");
4331+
if (trackDisjunction) {
4332+
(known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID);
4333+
} else {
4334+
state.groupNames[state.lastStringValue] = true;
4335+
}
42774336
}
42784337
};
42794338

@@ -5778,15 +5837,18 @@
57785837
break
57795838

57805839
case "$":
5781-
if (this.input[this.pos + 1] !== "{") {
5782-
break
5783-
}
5784-
5785-
// falls through
5840+
if (this.input[this.pos + 1] !== "{") { break }
5841+
// fall through
57865842
case "`":
57875843
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
57885844

5789-
// no default
5845+
case "\r":
5846+
if (this.input[this.pos + 1] === "\n") { ++this.pos; }
5847+
// fall through
5848+
case "\n": case "\u2028": case "\u2029":
5849+
++this.curLine;
5850+
this.lineStart = this.pos + 1;
5851+
break
57905852
}
57915853
}
57925854
this.raise(this.start, "Unterminated template");
@@ -5849,6 +5911,7 @@
58495911
if (isNewLine(ch)) {
58505912
// Unicode new line characters after \ get removed from output in both
58515913
// template literals and strings
5914+
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
58525915
return ""
58535916
}
58545917
return String.fromCharCode(ch)
@@ -5927,7 +5990,7 @@
59275990
// [walk]: util/walk.js
59285991

59295992

5930-
var version = "8.11.3";
5993+
var version = "8.12.1";
59315994

59325995
Parser.acorn = {
59335996
Parser: Parser,

0 commit comments

Comments
 (0)