This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 664
fix(rome_js_formatter): Fix stackoverflow on Windows for nested seque… #2469
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nce expressions Formatting deeply nested sequence expressions is causing a stack overflow on Windows because they are parsed left-recursive: ```js a, b,c,d ``` Parses to ```yaml JsExpressionStatement { expression: JsSequenceExpression { left: JsSequenceExpression { left: JsSequenceExpression { left: JsIdentifierExpression { name: JsReferenceIdentifier { value_token: IDENT@0..1 "a" [] [], }, }, comma_token: COMMA@1..3 "," [] [Whitespace(" ")], right: JsIdentifierExpression { name: JsReferenceIdentifier { value_token: IDENT@3..4 "b" [] [], }, }, }, comma_token: COMMA@4..5 "," [] [], right: JsIdentifierExpression { name: JsReferenceIdentifier { value_token: IDENT@5..6 "c" [] [], }, }, }, comma_token: COMMA@6..7 "," [] [], right: JsIdentifierExpression { name: JsReferenceIdentifier { value_token: IDENT@7..8 "d" [] [], }, }, }, semicolon_token: missing (optional), } ``` This PR changes the formatting of sequence expression to unwind the recursion by using a loop that first finds the left most sequence expression and then concatenates the expressions. ## test ``` cargo bench_formatter --filter d3 --criterion=false ``` No longer panics on Windows
!bench_formatter |
MichaReiser
requested review from
leops,
ematipico and
xunilrj
and removed request for
leops
April 20, 2022 08:55
Parser conformance results on ubuntu-latestjs/262
jsx/babel
ts/babel
ts/microsoft
|
xunilrj
approved these changes
Apr 20, 2022
Deploying with Cloudflare Pages
|
ematipico
approved these changes
Apr 20, 2022
while let Some(parent) = current.syntax().parent() { | ||
if let Some(parent_sequence) = JsSequenceExpression::cast(parent) { | ||
let JsSequenceExpressionFields { | ||
left: _left, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
left: _left, | |
left: _, |
we use _
already when we want to ignore a node
Formatter Benchmark Results
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…nce expressions
Formatting deeply nested sequence expressions is causing a stack overflow on Windows because they are parsed left-recursive:
Parses to
This PR changes the formatting of sequence expression to unwind the recursion by using a loop
that first finds the left most sequence expression and then concatenates the expressions.
test
No longer panics on Windows