Skip to content

Commit 7643ce9

Browse files
nodejs-github-botRafaelGSS
authored andcommitted
deps: update acorn to 8.15.0
PR-URL: #58711 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 2ba2c93 commit 7643ce9

File tree

8 files changed

+245
-39
lines changed

8 files changed

+245
-39
lines changed

deps/acorn/acorn/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 8.15.0 (2025-06-08)
2+
3+
### New features
4+
5+
Support `using` and `await using` syntax.
6+
7+
The `AnyNode` type is now defined in such a way that plugins can extend it.
8+
9+
### Bug fixes
10+
11+
Fix an issue where the `bigint` property of literal nodes for non-decimal bigints had the wrong format.
12+
13+
The `acorn` CLI tool no longer crashes when emitting a tree that contains a bigint.
14+
115
## 8.14.1 (2025-03-05)
216

317
### Bug fixes

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function {
169169
export interface VariableDeclaration extends Node {
170170
type: "VariableDeclaration"
171171
declarations: Array<VariableDeclarator>
172-
kind: "var" | "let" | "const"
172+
kind: "var" | "let" | "const" | "using" | "await using"
173173
}
174174

175175
export interface VariableDeclarator extends Node {
@@ -572,7 +572,24 @@ export type ModuleDeclaration =
572572
| ExportDefaultDeclaration
573573
| ExportAllDeclaration
574574

575-
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
575+
/**
576+
* This interface is only used for defining {@link AnyNode}.
577+
* It exists so that it can be extended by plugins:
578+
*
579+
* @example
580+
* ```typescript
581+
* declare module 'acorn' {
582+
* interface NodeTypes {
583+
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
584+
* }
585+
* }
586+
* ```
587+
*/
588+
interface NodeTypes {
589+
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
590+
}
591+
592+
export type AnyNode = NodeTypes[keyof NodeTypes]
576593

577594
export function parse(input: string, options: Options): Program
578595

@@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): {
583600
[Symbol.iterator](): Iterator<Token>
584601
}
585602

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

588605
export interface Options {
589606
/**

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function {
169169
export interface VariableDeclaration extends Node {
170170
type: "VariableDeclaration"
171171
declarations: Array<VariableDeclarator>
172-
kind: "var" | "let" | "const"
172+
kind: "var" | "let" | "const" | "using" | "await using"
173173
}
174174

175175
export interface VariableDeclarator extends Node {
@@ -572,7 +572,24 @@ export type ModuleDeclaration =
572572
| ExportDefaultDeclaration
573573
| ExportAllDeclaration
574574

575-
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
575+
/**
576+
* This interface is only used for defining {@link AnyNode}.
577+
* It exists so that it can be extended by plugins:
578+
*
579+
* @example
580+
* ```typescript
581+
* declare module 'acorn' {
582+
* interface NodeTypes {
583+
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
584+
* }
585+
* }
586+
* ```
587+
*/
588+
interface NodeTypes {
589+
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
590+
}
591+
592+
export type AnyNode = NodeTypes[keyof NodeTypes]
576593

577594
export function parse(input: string, options: Options): Program
578595

@@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): {
583600
[Symbol.iterator](): Iterator<Token>
584601
}
585602

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

588605
export interface Options {
589606
/**

deps/acorn/acorn/dist/acorn.js

Lines changed: 94 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,49 @@
887887
!(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
888888
};
889889

890+
pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
891+
if (this.options.ecmaVersion < 17 || !this.isContextual(isAwaitUsing ? "await" : "using"))
892+
{ return false }
893+
894+
skipWhiteSpace.lastIndex = this.pos;
895+
var skip = skipWhiteSpace.exec(this.input);
896+
var next = this.pos + skip[0].length;
897+
898+
if (lineBreak.test(this.input.slice(this.pos, next))) { return false }
899+
900+
if (isAwaitUsing) {
901+
var awaitEndPos = next + 5 /* await */, after;
902+
if (this.input.slice(next, awaitEndPos) !== "using" ||
903+
awaitEndPos === this.input.length ||
904+
isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) ||
905+
(after > 0xd7ff && after < 0xdc00)
906+
) { return false }
907+
908+
skipWhiteSpace.lastIndex = awaitEndPos;
909+
var skipAfterUsing = skipWhiteSpace.exec(this.input);
910+
if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false }
911+
}
912+
913+
if (isFor) {
914+
var ofEndPos = next + 2 /* of */, after$1;
915+
if (this.input.slice(next, ofEndPos) === "of") {
916+
if (ofEndPos === this.input.length ||
917+
(!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false }
918+
}
919+
}
920+
921+
var ch = this.input.charCodeAt(next);
922+
return isIdentifierStart(ch, true) || ch === 92 // '\'
923+
};
924+
925+
pp$8.isAwaitUsing = function(isFor) {
926+
return this.isUsingKeyword(true, isFor)
927+
};
928+
929+
pp$8.isUsing = function(isFor) {
930+
return this.isUsingKeyword(false, isFor)
931+
};
932+
890933
// Parse a single statement.
891934
//
892935
// If expecting a statement and finding a slash operator, parse a
@@ -963,6 +1006,23 @@
9631006
return this.parseFunctionStatement(node, true, !context)
9641007
}
9651008

1009+
var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
1010+
if (usingKind) {
1011+
if (topLevel && this.options.sourceType === "script") {
1012+
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`");
1013+
}
1014+
if (usingKind === "await using") {
1015+
if (!this.canAwait) {
1016+
this.raise(this.start, "Await using cannot appear outside of async function");
1017+
}
1018+
this.next();
1019+
}
1020+
this.next();
1021+
this.parseVar(node, false, usingKind);
1022+
this.semicolon();
1023+
return this.finishNode(node, "VariableDeclaration")
1024+
}
1025+
9661026
var maybeName = this.value, expr = this.parseExpression();
9671027
if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
9681028
{ return this.parseLabeledStatement(node, maybeName, expr, context) }
@@ -1038,18 +1098,19 @@
10381098
this.next();
10391099
this.parseVar(init$1, true, kind);
10401100
this.finishNode(init$1, "VariableDeclaration");
1041-
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
1042-
if (this.options.ecmaVersion >= 9) {
1043-
if (this.type === types$1._in) {
1044-
if (awaitAt > -1) { this.unexpected(awaitAt); }
1045-
} else { node.await = awaitAt > -1; }
1046-
}
1047-
return this.parseForIn(node, init$1)
1048-
}
1049-
if (awaitAt > -1) { this.unexpected(awaitAt); }
1050-
return this.parseFor(node, init$1)
1101+
return this.parseForAfterInit(node, init$1, awaitAt)
10511102
}
10521103
var startsWithLet = this.isContextual("let"), isForOf = false;
1104+
1105+
var usingKind = this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null;
1106+
if (usingKind) {
1107+
var init$2 = this.startNode();
1108+
this.next();
1109+
if (usingKind === "await using") { this.next(); }
1110+
this.parseVar(init$2, true, usingKind);
1111+
this.finishNode(init$2, "VariableDeclaration");
1112+
return this.parseForAfterInit(node, init$2, awaitAt)
1113+
}
10531114
var containsEsc = this.containsEsc;
10541115
var refDestructuringErrors = new DestructuringErrors;
10551116
var initPos = this.start;
@@ -1075,6 +1136,20 @@
10751136
return this.parseFor(node, init)
10761137
};
10771138

1139+
// Helper method to parse for loop after variable initialization
1140+
pp$8.parseForAfterInit = function(node, init, awaitAt) {
1141+
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
1142+
if (this.options.ecmaVersion >= 9) {
1143+
if (this.type === types$1._in) {
1144+
if (awaitAt > -1) { this.unexpected(awaitAt); }
1145+
} else { node.await = awaitAt > -1; }
1146+
}
1147+
return this.parseForIn(node, init)
1148+
}
1149+
if (awaitAt > -1) { this.unexpected(awaitAt); }
1150+
return this.parseFor(node, init)
1151+
};
1152+
10781153
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
10791154
this.next();
10801155
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
@@ -1331,6 +1406,8 @@
13311406
decl.init = this.parseMaybeAssign(isFor);
13321407
} else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
13331408
this.unexpected();
1409+
} else if (!allowMissingInitializer && (kind === "using" || kind === "await using") && this.options.ecmaVersion >= 17 && this.type !== types$1._in && !this.isContextual("of")) {
1410+
this.raise(this.lastTokEnd, ("Missing initializer in " + kind + " declaration"));
13341411
} else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
13351412
this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
13361413
} else {
@@ -1343,7 +1420,10 @@
13431420
};
13441421

13451422
pp$8.parseVarId = function(decl, kind) {
1346-
decl.id = this.parseBindingAtom();
1423+
decl.id = kind === "using" || kind === "await using"
1424+
? this.parseIdent()
1425+
: this.parseBindingAtom();
1426+
13471427
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
13481428
};
13491429

@@ -3074,7 +3154,8 @@
30743154
var node = this.startNode();
30753155
node.value = value;
30763156
node.raw = this.input.slice(this.start, this.end);
3077-
if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
3157+
if (node.raw.charCodeAt(node.raw.length - 1) === 110)
3158+
{ node.bigint = node.value != null ? node.value.toString() : node.raw.slice(0, -1).replace(/_/g, ""); }
30783159
this.next();
30793160
return this.finishNode(node, "Literal")
30803161
};
@@ -6104,11 +6185,9 @@
61046185
// Please use the [github bug tracker][ghbt] to report issues.
61056186
//
61066187
// [ghbt]: https://github.com/acornjs/acorn/issues
6107-
//
6108-
// [walk]: util/walk.js
61096188

61106189

6111-
var version = "8.14.1";
6190+
var version = "8.15.0";
61126191

61136192
Parser.acorn = {
61146193
Parser: Parser,

0 commit comments

Comments
 (0)