@@ -434,8 +434,10 @@ export class Parser {
434434
435435 const natSpecRegex = / ^ (?: @ ( \w + | c u s t o m : [ a - z ] [ a - z - ] * ) ) ? ( (?: (? ! ^ @ (?: \w + | c u s t o m : [ a - z ] [ a - z - ] * ) ) [ ^ ] ) * ) / gm;
436436
437- for ( const match of text . matchAll ( natSpecRegex ) ) {
438- const [ , tag = "notice" , rawText ] = match ;
437+ const matches = [ ...text . matchAll ( natSpecRegex ) ] ;
438+
439+ for ( let i = 0 ; i < matches . length ; i ++ ) {
440+ const [ , tag = "notice" , rawText ] = matches [ i ] ;
439441 const text = this . replaceMultipleNewLinesWithOne ( rawText ) ;
440442
441443 switch ( tag ) {
@@ -484,8 +486,14 @@ export class Parser {
484486
485487 const variableDeclaration = params . find ( ( param ) => param . name == paramName ) ;
486488
489+ // so that tag was not found, and it may be a return tag
487490 if ( ! variableDeclaration ) {
488- throw new Error ( `Invalid param name: ${ paramName } ` ) ;
491+ // protection from infinite loop
492+ if ( node . nodeType !== "EventDefinition" ) {
493+ matches [ i ] [ 1 ] = "return" ;
494+ i -- ;
495+ }
496+ break ;
489497 }
490498
491499 const type = variableDeclaration . typeDescriptions ?. typeString || undefined ;
@@ -495,6 +503,13 @@ export class Parser {
495503 break ;
496504 }
497505 case "return" : {
506+ // there is no return tag in events, so it is a param tag
507+ if ( node . nodeType === "EventDefinition" ) {
508+ matches [ i ] [ 1 ] = "param" ;
509+ i -- ;
510+ break ;
511+ }
512+
498513 natSpec . returns ??= [ ] ;
499514
500515 let currentParameter : VariableDeclaration = isNodeType ( "FunctionDefinition" , node )
0 commit comments