Skip to content

Commit f9208d4

Browse files
authored
[fix] Keep parens on raise calls with arg forwarding (#900)
* Fixtures * [fix] Keep parens on `raise` calls with arg forwarding
1 parent 0571ee5 commit f9208d4

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def a(...) = raise(...)
2+
3+
def b(...) = raise(self, ...)
4+
5+
def c(...)
6+
raise(ArgumentError, ...)
7+
end
8+
9+
class Error < StandardError
10+
def self.call(...) = raise(self, ...)
11+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def a(...) = raise(...)
2+
3+
def b(...) = raise(self, ...)
4+
5+
def c(...)
6+
raise(ArgumentError, ...)
7+
end
8+
9+
class Error < StandardError
10+
def self.call(...) = raise(self, ...)
11+
end

librubyfmt/src/format_prism.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,10 +1745,9 @@ fn use_parens_for_call_node<'src>(
17451745
}
17461746

17471747
if let Some(arguments) = call_node.arguments()
1748-
&& arguments
1749-
.arguments()
1750-
.iter()
1751-
.any(|arg| arg.as_splat_node().is_some())
1748+
&& arguments.arguments().iter().any(|arg| {
1749+
arg.as_splat_node().is_some() || arg.as_forwarding_arguments_node().is_some()
1750+
})
17521751
{
17531752
return true;
17541753
}

0 commit comments

Comments
 (0)