Skip to content

Commit 187727c

Browse files
committed
fix: don't remove parens around sequence expressions
1 parent 7a5767e commit 187727c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/parsing/parser.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,11 @@ fn should_skip_paren_expr(node: &ParenExpr, context: &Context) -> bool {
23982398
}
23992399
}
24002400

2401+
if matches!(node.expr.kind(), NodeKind::SeqExpr) {
2402+
// don't care about extra logic for sequence expressions
2403+
return false;
2404+
}
2405+
24012406
if matches!(node.expr.kind(), NodeKind::ArrayLit) {
24022407
return true;
24032408
}

tests/specs/expressions/SequenceExpression/SequenceExpression_All.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const x = (2, 3, 4);
77

88
== should format inside a member expression ==
99
member[1,2];
10-
member[(1,2)];
10+
member[(1,2)]; // could remove, but who writes this?
1111

1212
[expect]
1313
member[1, 2];
14-
member[1, 2];
14+
member[(1, 2)]; // could remove, but who writes this?
1515

1616
== should format multi-line with a hanging indent ==
1717
testttttttttting, thhhhisssouttttaaaabbitt, testing
@@ -20,3 +20,9 @@ testttttttttting, thhhhisssouttttaaaabbitt, testing
2020
testttttttttting,
2121
thhhhisssouttttaaaabbitt,
2222
testing;
23+
24+
== should not remove parens around the sequence expression in this bin expr ==
25+
c ??= (a++, b());
26+
27+
[expect]
28+
c ??= (a++, b());

0 commit comments

Comments
 (0)