Skip to content

Commit

Permalink
missed ref count
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Dec 4, 2024
1 parent 1fd1e9b commit 1573795
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test_programs/execution_success/reference_counts/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
let mut array = [0, 1, 2];
assert_refcount(array, 1);
assert_refcount(array, 2);

borrow(array, std::mem::array_refcount(array));
borrow_mut(&mut array, std::mem::array_refcount(array));
Expand All @@ -13,13 +13,13 @@ fn borrow(array: [Field; 3], rc_before_call: u32) {
}

fn borrow_mut(array: &mut [Field; 3], rc_before_call: u32) {
assert_refcount(*array, rc_before_call + 1); // Issue! This should be rc_before_call + 1
assert_refcount(*array, rc_before_call + 1);
array[0] = 5;
println(array[0]);
}

fn copy_mut(mut array: [Field; 3], rc_before_call: u32) {
assert_refcount(array, rc_before_call + 1); // Issue! This should be rc_before_call + 1
assert_refcount(array, rc_before_call + 1);
array[0] = 6;
println(array[0]);
}
Expand Down

0 comments on commit 1573795

Please sign in to comment.