Skip to content

Commit

Permalink
Fix recursion depth regression
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Jun 15, 2024
1 parent bc1416a commit e0d83c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Acornima.Extras/Jsx/JsxParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,6 @@ private JsxEmptyExpression ParseEmptyExpression()

ref readonly var tokenizer = ref _parser._tokenizer;
var startMarker = new Marker(tokenizer._lastTokenEnd, tokenizer._lastTokenEndLocation);
return _parser.FinishNodeAt(startMarker, _parser.StartNode(), new JsxEmptyExpression(), default);
return _parser.FinishNodeAt(startMarker, _parser.StartNode(), new JsxEmptyExpression());
}
}
2 changes: 1 addition & 1 deletion src/Acornima/Parser.Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ private Expression ParseParenAndDistinguishExpression(bool canBeArrow, Expressio
{
exprList[i] = (Expression)parameters[i];
}
val = FinishNodeAt(innerStartMarker, innerEndMarker, new SequenceExpression(NodeList.From(ref exprList)), default);
val = FinishNodeAt(innerStartMarker, innerEndMarker, new SequenceExpression(NodeList.From(ref exprList)));
}
else
{
Expand Down
12 changes: 10 additions & 2 deletions src/Acornima/Parser.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ internal Marker StartNode()
return new Marker(_tokenizer._start, _tokenizer._startLocation);
}

internal T FinishNodeAt<T>(in Marker startMarker, in Marker endMarker, T node, Ref<Scope> scope) where T : Node
internal T FinishNodeAt<T>(in Marker startMarker, in Marker endMarker, T node) where T : Node
{
// https://github.com/acornjs/acorn/blob/8.11.3/acorn/src/node.js > `function finishNodeAt`, `pp.finishNodeAt = function`

node._range = new Range(startMarker.Index, endMarker.Index);
node._location = new SourceLocation(startMarker.Position, endMarker.Position, _tokenizer._sourceFile);
_options._onNode?.Invoke(node, new OnNodeContext(default, _scopeStack));
return node;
}

internal T FinishNodeAt<T>(in Marker startMarker, in Marker endMarker, T node, Ref<Scope> scope) where T : Node
{
node._range = new Range(startMarker.Index, endMarker.Index);
node._location = new SourceLocation(startMarker.Position, endMarker.Position, _tokenizer._sourceFile);
_options._onNode?.Invoke(node, new OnNodeContext(scope, _scopeStack));
Expand All @@ -40,7 +48,7 @@ internal T FinishNode<T>(in Marker startMarker, T node) where T : Node
{
// https://github.com/acornjs/acorn/blob/8.11.3/acorn/src/node.js > `pp.finishNode = function`

return FinishNodeAt(startMarker, new Marker(_tokenizer._lastTokenEnd, _tokenizer._lastTokenEndLocation), node, default);
return FinishNodeAt(startMarker, new Marker(_tokenizer._lastTokenEnd, _tokenizer._lastTokenEndLocation), node);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit e0d83c9

Please sign in to comment.