Skip to content

Commit

Permalink
fix: preserve calldata visibility on return values
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 26, 2024
1 parent c63990e commit 7006362
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test_programs/execution_success/databus/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::std;

fn main(mut x: u32, y: call_datau32, z: call_data[u32; 4]) -> u32 {
fn main(mut x: u32, y: call_datau32, z: call_data[u32; 4]) -> return_data u32 {
let a = z[x];
a + foo(y)
}
Expand Down
6 changes: 4 additions & 2 deletions tooling/nargo_fmt/src/visitor/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ impl super::FmtVisitor<'_> {
result.push_str("distinct ");
}

if let Visibility::Public = func.def.return_visibility {
result.push_str("pub ");
match func.def.return_visibility {
Visibility::Public => result.push_str("pub "),
Visibility::DataBus => result.push_str("return_data "),
Visibility::Private => (),
}

let typ = rewrite::typ(self, self.shape(), func.return_type());
Expand Down

0 comments on commit 7006362

Please sign in to comment.