diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index be2fe844052..885826706a9 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -24,15 +24,14 @@ mod test; // Thus, the only argument to the `print` oracle is expected to always be an ident #[oracle(print)] -unconstrained fn print_oracle(_input: T) {} +unconstrained fn print_oracle(_input: T, _newline: bool) {} unconstrained pub fn print(input: T) { - print_oracle(input); + print_oracle(input, false); } unconstrained pub fn println(input: T) { - print(f"{input} -"); // skip a 2nd oracle call; use multi-line format to insert a newline + print_oracle(input, true); } #[foreign(recursive_aggregation)] diff --git a/tooling/nargo/src/ops/foreign_calls.rs b/tooling/nargo/src/ops/foreign_calls.rs index 7af31afc2c3..4ee0850ea24 100644 --- a/tooling/nargo/src/ops/foreign_calls.rs +++ b/tooling/nargo/src/ops/foreign_calls.rs @@ -129,7 +129,13 @@ impl DefaultForeignCallExecutor { fn execute_print(foreign_call_inputs: &[ForeignCallParam]) -> Result<(), ForeignCallError> { let display_values: PrintableValueDisplay = foreign_call_inputs.try_into()?; - print!("{display_values}"); + + if foreign_call_inputs[1].unwrap_value().is_zero() { + print!("{display_values}"); + } else { + println!("{display_values}"); + } + Ok(()) } }