diff --git a/tooling/nargo_fmt/src/visitor/expr.rs b/tooling/nargo_fmt/src/visitor/expr.rs index b5ff3e523bc..7677a6284ec 100644 --- a/tooling/nargo_fmt/src/visitor/expr.rs +++ b/tooling/nargo_fmt/src/visitor/expr.rs @@ -39,6 +39,16 @@ impl FmtVisitor<'_> { self.format_expr(infix.rhs) ) } + ExpressionKind::Call(call_expr) => { + let formatted_func = self.format_expr(*call_expr.func); + let formatted_args = call_expr + .arguments + .into_iter() + .map(|arg| self.format_expr(arg)) + .collect::>() + .join(", "); + format!("{}({})", formatted_func, formatted_args) + } ExpressionKind::MethodCall(method_call_expr) => { let formatted_object = self.format_expr(method_call_expr.object).trim().to_string(); let formatted_args = method_call_expr diff --git a/tooling/nargo_fmt/tests/expected/call.nr b/tooling/nargo_fmt/tests/expected/call.nr index ca4d5b82683..105a69acedc 100644 --- a/tooling/nargo_fmt/tests/expected/call.nr +++ b/tooling/nargo_fmt/tests/expected/call.nr @@ -1,3 +1,3 @@ -fn main() { - main(4, 3); +fn foo() { + my_function(10, some_value, another_func(20, 30)); } diff --git a/tooling/nargo_fmt/tests/input/call.nr b/tooling/nargo_fmt/tests/input/call.nr index 8927ebc85db..93d2597a05c 100644 --- a/tooling/nargo_fmt/tests/input/call.nr +++ b/tooling/nargo_fmt/tests/input/call.nr @@ -1,3 +1,3 @@ -fn main() { - main(4, 3); -} \ No newline at end of file +fn foo() { + my_function( 10,some_value,another_func( 20 , 30) ); +}