Skip to content

Commit 373ec2d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update acorn to 8.17.0
PR-URL: #63901 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 65178bd commit 373ec2d

8 files changed

Lines changed: 206 additions & 101 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.17.0 (2026-06-11)
2+
3+
### New features
4+
5+
The new `strict` option can be used to start script sources in strict mode.
6+
7+
### Bug fixes
8+
9+
Fix a number of corner case bugs when `using` or `await using` appear in `for` loop specs.
10+
11+
Disallow `new super()` expressions.
12+
13+
Don't allow the conditional in a ternary expression to be a (naked) arrow function.
14+
115
## 8.16.0 (2026-02-19)
216

317
### New features

‎deps/acorn/acorn/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ required):
8686
will be valid, even if `ecmaVersion` is less than 6. If set to `"commonjs"`,
8787
it is the same as `"script"` except that the top-level scope behaves like a function.
8888

89+
-**strict**: When set to true, enable strict parsing mode even if
90+
`sourceType` is `"script"`.
91+
8992
-**onInsertedSemicolon**: If given a callback, that callback will be
9093
called whenever a missing semicolon is inserted by the parser. The
9194
callback will be given the character offset of the point where the

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,12 @@ export interface Options {
619619
*/
620620
sourceType?: "script"|"module"|"commonjs"
621621

622+
/**
623+
* When set to true, enable strict parsing mode even if `sourceType`
624+
* is `"script"`.
625+
*/
626+
strict?: boolean
627+
622628
/**
623629
* a callback that will be called when a semicolon is automatically inserted.
624630
* @param lastTokEnd the position of the comma as an offset

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,12 @@ export interface Options {
619619
*/
620620
sourceType?: "script"|"module"|"commonjs"
621621

622+
/**
623+
* When set to true, enable strict parsing mode even if `sourceType`
624+
* is `"script"`.
625+
*/
626+
strict?: boolean
627+
622628
/**
623629
* a callback that will be called when a semicolon is automatically inserted.
624630
* @param lastTokEnd the position of the comma as an offset

‎deps/acorn/acorn/dist/acorn.js‎

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@
342342
// Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
343343
// strict mode and parsing of `import` and `export` declarations.
344344
sourceType: "script",
345+
// When set to true, enable strict parsing mode even if `sourceType`
346+
// is `"script"`.
347+
strict: false,
345348
// `onInsertedSemicolon` can be a callback that will be called when
346349
// a semicolon is automatically inserted. It will be passed the
347350
// position of the inserted semicolon as an offset, and if
@@ -568,7 +571,7 @@
568571

569572
// Figure out if it's a module code.
570573
this.inModule=options.sourceType==="module";
571-
this.strict=this.inModule||this.strictDirective(this.pos);
574+
this.strict=this.inModule||options.strict===true||this.strictDirective(this.pos);
572575

573576
// Used to signify the start of a potential arrow function
574577
this.potentialArrowAt=-1;
@@ -606,9 +609,11 @@
606609
varprototypeAccessors={inFunction: {configurable: true},inGenerator: {configurable: true},inAsync: {configurable: true},canAwait: {configurable: true},allowReturn: {configurable: true},allowSuper: {configurable: true},allowDirectSuper: {configurable: true},treatFunctionsAsVar: {configurable: true},allowNewDotTarget: {configurable: true},allowUsing: {configurable: true},inClassStaticBlock: {configurable: true}};
607610

608611
Parser.prototype.parse=functionparse(){
612+
varthis$1$1=this;
613+
609614
varnode=this.options.program||this.startNode();
610615
this.nextToken();
611-
returnthis.parseTopLevel(node)
616+
returnthis.catchStackOverflow(function(){returnthis$1$1.parseTopLevel(node);})
612617
};
613618

614619
prototypeAccessors.inFunction.get=function(){return(this.currentVarScope().flags&SCOPE_FUNCTION)>0};
@@ -747,6 +752,17 @@
747752
returntrue
748753
};
749754

755+
pp$9.catchStackOverflow=function(f){
756+
try{
757+
returnf()
758+
}catch(e){
759+
if(einstanceofError&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoomuchrecursion\b/i.test(e.message)))
760+
{this.raise(this.start,"Not enough stack space to parse input");}
761+
else
762+
{throwe}
763+
}
764+
};
765+
750766
// Asserts that following token is given contextual keyword.
751767

752768
pp$9.expectContextual=function(name){
@@ -850,10 +866,10 @@
850866
// to its body instead of creating a new node.
851867

852868
pp$8.parseTopLevel=function(node){
853-
varexports=Object.create(null);
869+
varexports$1=Object.create(null);
854870
if(!node.body){node.body=[];}
855871
while(this.type!==types$1.eof){
856-
varstmt=this.parseStatement(null,true,exports);
872+
varstmt=this.parseStatement(null,true,exports$1);
857873
node.body.push(stmt);
858874
}
859875
if(this.inModule)
@@ -942,7 +958,18 @@
942958
while(isIdentifierChar(ch=this.fullCharCodeAt(next)))
943959
if(ch===92){returntrue}
944960
varid=this.input.slice(idStart,next);
945-
if(keywordRelationalOperator.test(id)||isFor&&id==="of"){returnfalse}
961+
if(keywordRelationalOperator.test(id)){returnfalse}
962+
if(isFor&&!isAwaitUsing&&id==="of"){
963+
// Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
964+
skipWhiteSpace.lastIndex=next;
965+
varskipAfterOf=skipWhiteSpace.exec(this.input);
966+
next=next+skipAfterOf[0].length;
967+
if(this.input.charCodeAt(next)!==61/* '=' */||
968+
// Check for ==, === and => operators
969+
(ch=this.input.charCodeAt(next+1))===61/* '=' */||ch===62/* '>' */){
970+
returnfalse
971+
}
972+
}
946973
returntrue
947974
};
948975

@@ -961,7 +988,7 @@
961988
// `if (foo) /blah/.exec(foo)`, where looking at the previous token
962989
// does not help.
963990

964-
pp$8.parseStatement=function(context,topLevel,exports){
991+
pp$8.parseStatement=function(context,topLevel,exports$1){
965992
varstarttype=this.type,node=this.startNode(),kind;
966993

967994
if(this.isLet(context)){
@@ -1016,7 +1043,7 @@
10161043
if(!this.inModule)
10171044
{this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'");}
10181045
}
1019-
returnstarttype===types$1._import ? this.parseImport(node) : this.parseExport(node,exports)
1046+
returnstarttype===types$1._import ? this.parseImport(node) : this.parseExport(node,exports$1)
10201047

10211048
// If the statement does not start with a statement keyword or a
10221049
// brace, it's an ExpressionStatement or LabeledStatement. We
@@ -1035,6 +1062,10 @@
10351062
if(!this.allowUsing){
10361063
this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
10371064
}
1065+
if(context){
1066+
// Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
1067+
this.raise(this.start,"Using declaration is not allowed in single-statement positions");
1068+
}
10381069
if(usingKind==="await using"){
10391070
if(!this.canAwait){
10401071
this.raise(this.start,"Await using cannot appear outside of async function");
@@ -1168,11 +1199,12 @@
11681199
// Helper method to parse for loop after variable initialization
11691200
pp$8.parseForAfterInit=function(node,init,awaitAt){
11701201
if((this.type===types$1._in||(this.options.ecmaVersion>=6&&this.isContextual("of")))&&init.declarations.length===1){
1171-
if(this.options.ecmaVersion>=9){
1172-
if(this.type===types$1._in){
1173-
if(awaitAt>-1){this.unexpected(awaitAt);}
1174-
}else{node.await=awaitAt>-1;}
1175-
}
1202+
if(this.type===types$1._in){
1203+
if((init.kind==="using"||init.kind==="await using")&&!init.declarations[0].init){
1204+
this.raise(this.start,"Using declaration is not allowed in for-in loops");
1205+
}
1206+
if(this.options.ecmaVersion>=9&&awaitAt>-1){this.unexpected(awaitAt);}
1207+
}elseif(this.options.ecmaVersion>=9){node.await=awaitAt>-1;}
11761208
returnthis.parseForIn(node,init)
11771209
}
11781210
if(awaitAt>-1){this.unexpected(awaitAt);}
@@ -1777,11 +1809,11 @@
17771809

17781810
// Parses module export declaration.
17791811

1780-
pp$8.parseExportAllDeclaration=function(node,exports){
1812+
pp$8.parseExportAllDeclaration=function(node,exports$1){
17811813
if(this.options.ecmaVersion>=11){
17821814
if(this.eatContextual("as")){
17831815
node.exported=this.parseModuleExportName();
1784-
this.checkExport(exports,node.exported,this.lastTokStart);
1816+
this.checkExport(exports$1,node.exported,this.lastTokStart);
17851817
}else{
17861818
node.exported=null;
17871819
}
@@ -1795,31 +1827,31 @@
17951827
returnthis.finishNode(node,"ExportAllDeclaration")
17961828
};
17971829

1798-
pp$8.parseExport=function(node,exports){
1830+
pp$8.parseExport=function(node,exports$1){
17991831
this.next();
18001832
// export * from '...'
18011833
if(this.eat(types$1.star)){
1802-
returnthis.parseExportAllDeclaration(node,exports)
1834+
returnthis.parseExportAllDeclaration(node,exports$1)
18031835
}
18041836
if(this.eat(types$1._default)){// export default ...
1805-
this.checkExport(exports,"default",this.lastTokStart);
1837+
this.checkExport(exports$1,"default",this.lastTokStart);
18061838
node.declaration=this.parseExportDefaultDeclaration();
18071839
returnthis.finishNode(node,"ExportDefaultDeclaration")
18081840
}
18091841
// export var|const|let|function|class ...
18101842
if(this.shouldParseExportStatement()){
18111843
node.declaration=this.parseExportDeclaration(node);
18121844
if(node.declaration.type==="VariableDeclaration")
1813-
{this.checkVariableExport(exports,node.declaration.declarations);}
1845+
{this.checkVariableExport(exports$1,node.declaration.declarations);}
18141846
else
1815-
{this.checkExport(exports,node.declaration.id,node.declaration.id.start);}
1847+
{this.checkExport(exports$1,node.declaration.id,node.declaration.id.start);}
18161848
node.specifiers=[];
18171849
node.source=null;
18181850
if(this.options.ecmaVersion>=16)
18191851
{node.attributes=[];}
18201852
}else{// export { x, y as z } [from '...']
18211853
node.declaration=null;
1822-
node.specifiers=this.parseExportSpecifiers(exports);
1854+
node.specifiers=this.parseExportSpecifiers(exports$1);
18231855
if(this.eatContextual("from")){
18241856
if(this.type!==types$1.string){this.unexpected();}
18251857
node.source=this.parseExprAtom();
@@ -1869,47 +1901,47 @@
18691901
}
18701902
};
18711903

1872-
pp$8.checkExport=function(exports,name,pos){
1873-
if(!exports){return}
1904+
pp$8.checkExport=function(exports$1,name,pos){
1905+
if(!exports$1){return}
18741906
if(typeofname!=="string")
18751907
{name=name.type==="Identifier" ? name.name : name.value;}
1876-
if(hasOwn(exports,name))
1908+
if(hasOwn(exports$1,name))
18771909
{this.raiseRecoverable(pos,"Duplicate export '"+name+"'");}
1878-
exports[name]=true;
1910+
exports$1[name]=true;
18791911
};
18801912

1881-
pp$8.checkPatternExport=function(exports,pat){
1913+
pp$8.checkPatternExport=function(exports$1,pat){
18821914
vartype=pat.type;
18831915
if(type==="Identifier")
1884-
{this.checkExport(exports,pat,pat.start);}
1916+
{this.checkExport(exports$1,pat,pat.start);}
18851917
elseif(type==="ObjectPattern")
18861918
{for(vari=0,list=pat.properties;i<list.length;i+=1)
18871919
{
18881920
varprop=list[i];
18891921

1890-
this.checkPatternExport(exports,prop);
1922+
this.checkPatternExport(exports$1,prop);
18911923
}}
18921924
elseif(type==="ArrayPattern")
18931925
{for(vari$1=0,list$1=pat.elements;i$1<list$1.length;i$1+=1){
18941926
varelt=list$1[i$1];
18951927

1896-
if(elt){this.checkPatternExport(exports,elt);}
1928+
if(elt){this.checkPatternExport(exports$1,elt);}
18971929
}}
18981930
elseif(type==="Property")
1899-
{this.checkPatternExport(exports,pat.value);}
1931+
{this.checkPatternExport(exports$1,pat.value);}
19001932
elseif(type==="AssignmentPattern")
1901-
{this.checkPatternExport(exports,pat.left);}
1933+
{this.checkPatternExport(exports$1,pat.left);}
19021934
elseif(type==="RestElement")
1903-
{this.checkPatternExport(exports,pat.argument);}
1935+
{this.checkPatternExport(exports$1,pat.argument);}
19041936
};
19051937

1906-
pp$8.checkVariableExport=function(exports,decls){
1907-
if(!exports){return}
1938+
pp$8.checkVariableExport=function(exports$1,decls){
1939+
if(!exports$1){return}
19081940
for(vari=0,list=decls;i<list.length;i+=1)
19091941
{
19101942
vardecl=list[i];
19111943

1912-
this.checkPatternExport(exports,decl.id);
1944+
this.checkPatternExport(exports$1,decl.id);
19131945
}
19141946
};
19151947

@@ -1924,21 +1956,21 @@
19241956

19251957
// Parses a comma-separated list of module exports.
19261958

1927-
pp$8.parseExportSpecifier=function(exports){
1959+
pp$8.parseExportSpecifier=function(exports$1){
19281960
varnode=this.startNode();
19291961
node.local=this.parseModuleExportName();
19301962

19311963
node.exported=this.eatContextual("as") ? this.parseModuleExportName() : node.local;
19321964
this.checkExport(
1933-
exports,
1965+
exports$1,
19341966
node.exported,
19351967
node.exported.start
19361968
);
19371969

19381970
returnthis.finishNode(node,"ExportSpecifier")
19391971
};
19401972

1941-
pp$8.parseExportSpecifiers=function(exports){
1973+
pp$8.parseExportSpecifiers=function(exports$1){
19421974
varnodes=[],first=true;
19431975
// export { x, y as z } [from '...']
19441976
this.expect(types$1.braceL);
@@ -1948,7 +1980,7 @@
19481980
if(this.afterTrailingComma(types$1.braceR)){break}
19491981
}else{first=false;}
19501982

1951-
nodes.push(this.parseExportSpecifier(exports));
1983+
nodes.push(this.parseExportSpecifier(exports$1));
19521984
}
19531985
returnnodes
19541986
};
@@ -2679,15 +2711,19 @@
26792711
// delayed syntax error at correct position).
26802712

26812713
pp$5.parseExpression=function(forInit,refDestructuringErrors){
2682-
varstartPos=this.start,startLoc=this.startLoc;
2683-
varexpr=this.parseMaybeAssign(forInit,refDestructuringErrors);
2684-
if(this.type===types$1.comma){
2685-
varnode=this.startNodeAt(startPos,startLoc);
2686-
node.expressions=[expr];
2687-
while(this.eat(types$1.comma)){node.expressions.push(this.parseMaybeAssign(forInit,refDestructuringErrors));}
2688-
returnthis.finishNode(node,"SequenceExpression")
2689-
}
2690-
returnexpr
2714+
varthis$1$1=this;
2715+
2716+
returnthis.catchStackOverflow(function(){
2717+
varstartPos=this$1$1.start,startLoc=this$1$1.startLoc;
2718+
varexpr=this$1$1.parseMaybeAssign(forInit,refDestructuringErrors);
2719+
if(this$1$1.type===types$1.comma){
2720+
varnode=this$1$1.startNodeAt(startPos,startLoc);
2721+
node.expressions=[expr];
2722+
while(this$1$1.eat(types$1.comma)){node.expressions.push(this$1$1.parseMaybeAssign(forInit,refDestructuringErrors));}
2723+
returnthis$1$1.finishNode(node,"SequenceExpression")
2724+
}
2725+
returnexpr
2726+
})
26912727
};
26922728

26932729
// Parse an assignment expression. This includes applications of
@@ -2752,7 +2788,7 @@
27522788
varstartPos=this.start,startLoc=this.startLoc;
27532789
varexpr=this.parseExprOps(forInit,refDestructuringErrors);
27542790
if(this.checkExpressionErrors(refDestructuringErrors)){returnexpr}
2755-
if(this.eat(types$1.question)){
2791+
if(!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&this.eat(types$1.question)){
27562792
varnode=this.startNodeAt(startPos,startLoc);
27572793
node.test=expr;
27582794
node.consequent=this.parseMaybeAssign();
@@ -3304,6 +3340,8 @@
33043340
}
33053341
varstartPos=this.start,startLoc=this.startLoc;
33063342
node.callee=this.parseSubscripts(this.parseExprAtom(null,false,true),startPos,startLoc,true,false);
3343+
if(node.callee.type==="Super")
3344+
{this.raiseRecoverable(startPos,"Invalid use of 'super'");}
33073345
if(this.eat(types$1.parenL)){node.arguments=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,false);}
33083346
else{node.arguments=empty;}
33093347
returnthis.finishNode(node,"NewExpression")
@@ -6220,7 +6258,7 @@
62206258
// [ghbt]: https://github.com/acornjs/acorn/issues
62216259

62226260

6223-
varversion="8.16.0";
6261+
varversion="8.17.0";
62246262

62256263
Parser.acorn={
62266264
Parser: Parser,

0 commit comments

Comments
 (0)