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 <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 2ba2c93 commit 7643ce9

8 files changed

Lines changed: 245 additions & 39 deletions

File tree

‎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
exportinterfaceVariableDeclarationextendsNode{
170170
type: "VariableDeclaration"
171171
declarations: Array<VariableDeclarator>
172-
kind: "var"|"let"|"const"
172+
kind: "var"|"let"|"const"|"using"|"await using"
173173
}
174174

175175
exportinterfaceVariableDeclaratorextendsNode{
@@ -572,7 +572,24 @@ export type ModuleDeclaration =
572572
|ExportDefaultDeclaration
573573
|ExportAllDeclaration
574574

575-
exporttypeAnyNode=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+
interfaceNodeTypes{
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+
exporttypeAnyNode=NodeTypes[keyofNodeTypes]
576593

577594
exportfunctionparse(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-
exporttypeecmaVersion=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+
exporttypeecmaVersion=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
exportinterfaceOptions{
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
exportinterfaceVariableDeclarationextendsNode{
170170
type: "VariableDeclaration"
171171
declarations: Array<VariableDeclarator>
172-
kind: "var"|"let"|"const"
172+
kind: "var"|"let"|"const"|"using"|"await using"
173173
}
174174

175175
exportinterfaceVariableDeclaratorextendsNode{
@@ -572,7 +572,24 @@ export type ModuleDeclaration =
572572
|ExportDefaultDeclaration
573573
|ExportAllDeclaration
574574

575-
exporttypeAnyNode=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+
interfaceNodeTypes{
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+
exporttypeAnyNode=NodeTypes[keyofNodeTypes]
576593

577594
exportfunctionparse(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-
exporttypeecmaVersion=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+
exporttypeecmaVersion=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
exportinterfaceOptions{
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+
{returnfalse}
893+
894+
skipWhiteSpace.lastIndex=this.pos;
895+
varskip=skipWhiteSpace.exec(this.input);
896+
varnext=this.pos+skip[0].length;
897+
898+
if(lineBreak.test(this.input.slice(this.pos,next))){returnfalse}
899+
900+
if(isAwaitUsing){
901+
varawaitEndPos=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+
){returnfalse}
907+
908+
skipWhiteSpace.lastIndex=awaitEndPos;
909+
varskipAfterUsing=skipWhiteSpace.exec(this.input);
910+
if(skipAfterUsing&&lineBreak.test(this.input.slice(awaitEndPos,awaitEndPos+skipAfterUsing[0].length))){returnfalse}
911+
}
912+
913+
if(isFor){
914+
varofEndPos=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))){returnfalse}
918+
}
919+
}
920+
921+
varch=this.input.charCodeAt(next);
922+
returnisIdentifierStart(ch,true)||ch===92// '\'
923+
};
924+
925+
pp$8.isAwaitUsing=function(isFor){
926+
returnthis.isUsingKeyword(true,isFor)
927+
};
928+
929+
pp$8.isUsing=function(isFor){
930+
returnthis.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
returnthis.parseFunctionStatement(node,true,!context)
9641007
}
9651008

1009+
varusingKind=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+
returnthis.finishNode(node,"VariableDeclaration")
1024+
}
1025+
9661026
varmaybeName=this.value,expr=this.parseExpression();
9671027
if(starttype===types$1.name&&expr.type==="Identifier"&&this.eat(types$1.colon))
9681028
{returnthis.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-
returnthis.parseForIn(node,init$1)
1048-
}
1049-
if(awaitAt>-1){this.unexpected(awaitAt);}
1050-
returnthis.parseFor(node,init$1)
1101+
returnthis.parseForAfterInit(node,init$1,awaitAt)
10511102
}
10521103
varstartsWithLet=this.isContextual("let"),isForOf=false;
1104+
1105+
varusingKind=this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null;
1106+
if(usingKind){
1107+
varinit$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+
returnthis.parseForAfterInit(node,init$2,awaitAt)
1113+
}
10531114
varcontainsEsc=this.containsEsc;
10541115
varrefDestructuringErrors=newDestructuringErrors;
10551116
varinitPos=this.start;
@@ -1075,6 +1136,20 @@
10751136
returnthis.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+
returnthis.parseForIn(node,init)
1148+
}
1149+
if(awaitAt>-1){this.unexpected(awaitAt);}
1150+
returnthis.parseFor(node,init)
1151+
};
1152+
10781153
pp$8.parseFunctionStatement=function(node,isAsync,declarationPosition){
10791154
this.next();
10801155
returnthis.parseFunction(node,FUNC_STATEMENT|(declarationPosition ? 0 : FUNC_HANGING_STATEMENT),false,isAsync)
@@ -1331,6 +1406,8 @@
13311406
decl.init=this.parseMaybeAssign(isFor);
13321407
}elseif(!allowMissingInitializer&&kind==="const"&&!(this.type===types$1._in||(this.options.ecmaVersion>=6&&this.isContextual("of")))){
13331408
this.unexpected();
1409+
}elseif(!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
}elseif(!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
varnode=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
returnthis.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-
varversion="8.14.1";
6190+
varversion="8.15.0";
61126191

61136192
Parser.acorn={
61146193
Parser: Parser,

0 commit comments

Comments
 (0)