diff --git a/tooling/nargo_fmt/src/visitor/stmt.rs b/tooling/nargo_fmt/src/visitor/stmt.rs index b414e5ec5c3..44c5dad6b5d 100644 --- a/tooling/nargo_fmt/src/visitor/stmt.rs +++ b/tooling/nargo_fmt/src/visitor/stmt.rs @@ -38,7 +38,10 @@ impl super::FmtVisitor<'_> { nested_shape.indent.block_indent(self.config); - let message = message.map_or(String::new(), |message| format!(", {message}")); + let message = message.map_or(String::new(), |message| { + let message = rewrite::sub_expr(self, nested_shape, message); + format!(", {message}") + }); let (callee, args) = match kind { ConstrainKind::Assert | ConstrainKind::Constrain => { diff --git a/tooling/nargo_fmt/tests/expected/assert.nr b/tooling/nargo_fmt/tests/expected/assert.nr index 1f38e56b799..805e069c9a7 100644 --- a/tooling/nargo_fmt/tests/expected/assert.nr +++ b/tooling/nargo_fmt/tests/expected/assert.nr @@ -1,4 +1,5 @@ fn main(x: Field) { assert(x == 0, "with a message"); assert_eq(x, 1); + assert(x, message); } diff --git a/tooling/nargo_fmt/tests/input/assert.nr b/tooling/nargo_fmt/tests/input/assert.nr index f41e396c041..d0259da0e24 100644 --- a/tooling/nargo_fmt/tests/input/assert.nr +++ b/tooling/nargo_fmt/tests/input/assert.nr @@ -4,4 +4,5 @@ fn main(x: Field) { x, 1 ); + assert( x, message ); }