diff --git a/compiler/noirc_frontend/src/elaborator/function.rs b/compiler/noirc_frontend/src/elaborator/function.rs index 24859991325..9797a8b83a3 100644 --- a/compiler/noirc_frontend/src/elaborator/function.rs +++ b/compiler/noirc_frontend/src/elaborator/function.rs @@ -486,6 +486,7 @@ impl Elaborator<'_> { self.local_module = Some(func_meta.source_module); self.self_type = func_meta.self_type.clone(); self.current_trait_impl = func_meta.trait_impl; + self.reset_lvalue_index_counter(); self.scopes.start_function(); let old_item = self.current_item.replace(DependencyId::Function(id)); diff --git a/compiler/noirc_frontend/src/elaborator/globals.rs b/compiler/noirc_frontend/src/elaborator/globals.rs index bf2c00a9286..cead8e63c51 100644 --- a/compiler/noirc_frontend/src/elaborator/globals.rs +++ b/compiler/noirc_frontend/src/elaborator/globals.rs @@ -87,6 +87,7 @@ impl Elaborator<'_> { self.push_err(ResolverError::MutableGlobal { location }); } + self.reset_lvalue_index_counter(); let (let_statement, _typ) = self.elaborate_let(let_stmt, Some(global_id)); // References cannot be stored in globals because they would outlive their referents. diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index ecef7183994..3c8b53eab21 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -293,6 +293,22 @@ pub struct Elaborator<'context> { /// when an attribute generates code that triggers further attribute expansion. /// This is a global counter that catches both single-function and mutual recursion. pub(crate) macro_expansion_depth: usize, + + /// Counter used to define temporary variables for non-simple indexes in l-values. + /// + /// For example, this expression: + /// + /// ```noir + /// array[x + y] = 10; + /// ``` + /// + /// is transformed into: + /// + /// ```noir + /// let i_0 = x + y; + /// array[i_0] = 10; + /// ``` + lvalue_index_counter: usize, } #[derive(Copy, Clone)] @@ -363,6 +379,7 @@ impl<'context> Elaborator<'context> { elaborate_reasons, comptime_evaluation_halted: false, macro_expansion_depth: 0, + lvalue_index_counter: 0, } } @@ -838,6 +855,16 @@ impl<'context> Elaborator<'context> { pub(crate) fn interpreter_call_stack(&self) -> &im::Vector { &self.interpreter_call_stack } + + pub(crate) fn reset_lvalue_index_counter(&mut self) { + self.lvalue_index_counter = 0; + } + + pub(crate) fn next_lvalue_index_counter(&mut self) -> usize { + let lvalue_index_counter = self.lvalue_index_counter; + self.lvalue_index_counter += 1; + lvalue_index_counter + } } #[cfg(feature = "test_utils")] diff --git a/compiler/noirc_frontend/src/elaborator/statements.rs b/compiler/noirc_frontend/src/elaborator/statements.rs index 8fdf90efc07..bbb2f32a33a 100644 --- a/compiler/noirc_frontend/src/elaborator/statements.rs +++ b/compiler/noirc_frontend/src/elaborator/statements.rs @@ -719,8 +719,9 @@ impl Elaborator<'_> { return None; } + let lvalue_index_counter = self.next_lvalue_index_counter(); let id = self.interner.push_definition( - format!("i_{}", self.interner.definition_count()), + format!("i_{lvalue_index_counter}"), false, false, DefinitionKind::Local(None), diff --git a/compiler/noirc_frontend/src/tests/assignment.rs b/compiler/noirc_frontend/src/tests/assignment.rs index 87625f144d1..76f521f31aa 100644 --- a/compiler/noirc_frontend/src/tests/assignment.rs +++ b/compiler/noirc_frontend/src/tests/assignment.rs @@ -35,15 +35,15 @@ fn mutate_in_lvalue_block_expr() { mutate_in_lvalue(); (); } - + fn mutate_in_lvalue() { let mut a: ([Field; 2], Field) = ([1_Field, 2_Field], 3_Field); { - let i_3: u32 = { + let i_0: u32 = { a = ([4_Field, 5_Field], 6_Field); 1_u32 }; - a.0[i_3] = 7_Field; + a.0[i_0] = 7_Field; }; assert(a.0[0_u32] == 4_Field); assert(a.0[1_u32] == 7_Field); @@ -81,15 +81,15 @@ fn multiple_block_expressions_in_lvalue() { fn main() { let mut arr: [[Field; 2]; 2] = [[1_Field, 2_Field], [3_Field, 4_Field]]; { - let i_2: u32 = { + let i_0: u32 = { arr = [[5_Field, 6_Field], [7_Field, 8_Field]]; 0_u32 }; - let i_3: u32 = { + let i_1: u32 = { arr[0_u32][0_u32] = 9_Field; 1_u32 }; - arr[i_2][i_3] = 10_Field; + arr[i_0][i_1] = 10_Field; }; assert(arr[0_u32][0_u32] == 9_Field); assert(arr[0_u32][1_u32] == 10_Field); @@ -134,7 +134,7 @@ fn deeply_nested_block_expressions_in_lvalue() { fn main() { let mut arr: [[Field; 2]; 2] = [[1_Field, 2_Field], [3_Field, 4_Field]]; { - let i_3: u32 = { + let i_0: u32 = { let x: u32 = { arr = [[10_Field, 20_Field], [30_Field, 40_Field]]; 0_u32 @@ -142,11 +142,11 @@ fn deeply_nested_block_expressions_in_lvalue() { arr = [[100_Field, 200_Field], [300_Field, 400_Field]]; x }; - let i_4: u32 = { + let i_1: u32 = { arr = [[1000_Field, 2000_Field], [3000_Field, 4000_Field]]; 1_u32 }; - arr[i_3][i_4] = 5000_Field; + arr[i_0][i_1] = 5000_Field; }; assert(arr[0_u32][0_u32] == 1000_Field); assert(arr[0_u32][1_u32] == 5000_Field); @@ -184,15 +184,15 @@ fn nested_array_index_side_effect_ordering() { *c = *c + 1_Field; old as u32 } - + fn main() { let mut counter: Field = 0_Field; let mut arr: [[[Field; 2]; 2]; 2] = [[[0_Field; 2]; 2]; 2]; { - let i_6: u32 = inc(&mut counter); - let i_7: u32 = inc(&mut counter); - let i_8: u32 = inc(&mut counter); - arr[i_6][i_7][i_8] = 42_Field; + let i_0: u32 = inc(&mut counter); + let i_1: u32 = inc(&mut counter); + let i_2: u32 = inc(&mut counter); + arr[i_0][i_1][i_2] = 42_Field; }; assert(counter == 3_Field); assert(arr[0_u32][1_u32][2_u32] == 42_Field); @@ -230,20 +230,20 @@ fn member_access_then_array_index_ordering() { struct Foo { arrays: [[Field; 2]; 2], } - + fn inc(c: &mut Field) -> u32 { let old: Field = *c; *c = *c + 1_Field; old as u32 } - + fn main() { let mut counter: Field = 0_Field; let mut foo: Foo = Foo { arrays: [[0_Field; 2]; 2]}; { - let i_6: u32 = inc(&mut counter); - let i_7: u32 = inc(&mut counter); - foo.arrays[i_6][i_7] = 55_Field; + let i_0: u32 = inc(&mut counter); + let i_1: u32 = inc(&mut counter); + foo.arrays[i_0][i_1] = 55_Field; }; assert(counter == 2_Field); assert(foo.arrays[0_u32][1_u32] == 55_Field); diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/arithmetic_generics/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/arithmetic_generics/execute__tests__expanded.snap index 18efa8a6014..b3429666a85 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/arithmetic_generics/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/arithmetic_generics/execute__tests__expanded.snap @@ -24,8 +24,8 @@ fn split_first(array: [T; N]) -> (T, [T; N - 1]) { fn push(array: [Field; N], element: Field) -> [Field; N + 1] { let mut result: [Field; N + 1] = std::mem::zeroed(); { - let i_4473: u32 = array.len(); - result[i_4473] = element; + let i_0: u32 = array.len(); + result[i_0] = element; }; for i in 0_u32..array.len() { result[i] = array[i]; diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/assign_mutation_in_lvalue/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/assign_mutation_in_lvalue/execute__tests__expanded.snap index db625ee3172..3285a3fb64f 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/assign_mutation_in_lvalue/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/assign_mutation_in_lvalue/execute__tests__expanded.snap @@ -10,11 +10,11 @@ fn main() { fn bug() { let mut a: ([Field; 2], Field) = ([1_Field, 2_Field], 3_Field); { - let i_4442: u32 = { + let i_0: u32 = { a = ([4_Field, 5_Field], 6_Field); 1_u32 }; - a.0[i_4442] = 7_Field; + a.0[i_0] = 7_Field; }; assert(a == ([4_Field, 7_Field], 6_Field)); } diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics/execute__tests__expanded.snap index eea3fa5d448..4c46a8fae81 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics/execute__tests__expanded.snap @@ -27,8 +27,8 @@ impl MyStruct { fn insert(mut self, index: Field, elem: Field) -> Self { assert((index as u64) < (S as u64)); { - let i_4456: u32 = index as u32; - self.data[i_4456] = elem; + let i_0: u32 = index as u32; + self.data[i_0] = elem; }; self } diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics_explicit/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics_explicit/execute__tests__expanded.snap index 77d8d74f6e0..28e94c291b0 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics_explicit/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/numeric_generics_explicit/execute__tests__expanded.snap @@ -36,8 +36,8 @@ impl MyStruct { fn insert(mut self, index: Field, elem: Field) -> Self { assert((index as u32) < S); { - let i_4474: u32 = index as u32; - self.data[i_4474] = elem; + let i_0: u32 = index as u32; + self.data[i_0] = elem; }; self } diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/regression_bignum/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/regression_bignum/execute__tests__expanded.snap index 71795e18df5..1dde71ef43d 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/regression_bignum/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/regression_bignum/execute__tests__expanded.snap @@ -53,8 +53,8 @@ unconstrained fn shl(shift: u32) -> [u64; 6] { result[num_shifted_limbs] = 1_u64 << limb_shift; for i in 1_u32..6_u32 - num_shifted_limbs { { - let i_4463: u32 = i + num_shifted_limbs; - result[i_4463] = 0_u64; + let i_0: u32 = i + num_shifted_limbs; + result[i_0] = 0_u64; } } result diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_1/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_1/execute__tests__expanded.snap index e9a41728689..3328d1e1f05 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_1/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_1/execute__tests__expanded.snap @@ -25,8 +25,8 @@ where } for i in 0_u32..b.len() { { - let i_4465: u32 = i + a.len(); - array[i_4465] = b[i]; + let i_0: u32 = i + a.len(); + array[i_0] = b[i]; } } array diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_4/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_4/execute__tests__expanded.snap index 56cd0ce20a9..c1df8155f22 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_4/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_empty/serialize_4/execute__tests__expanded.snap @@ -25,8 +25,8 @@ where } for i in 0_u32..b.len() { { - let i_4465: u32 = i + a.len(); - array[i_4465] = b[i]; + let i_0: u32 = i + a.len(); + array[i_0] = b[i]; } } array diff --git a/tooling/nargo_cli/tests/snapshots/compile_success_no_bug/ram_blowup_regression/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/compile_success_no_bug/ram_blowup_regression/execute__tests__expanded.snap index 830ef90c213..d5b5fc71ec2 100644 --- a/tooling/nargo_cli/tests/snapshots/compile_success_no_bug/ram_blowup_regression/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/compile_success_no_bug/ram_blowup_regression/execute__tests__expanded.snap @@ -29,8 +29,8 @@ fn main(tx_effects_hash_input: [Field; 256]) -> pub Field { let input_as_bytes: [u8; 32] = tx_effects_hash_input[offset].to_be_bytes(); for byte_index in 0_u32..32_u32 { { - let i_4457: u32 = (offset * 32_u32) + byte_index; - hash_input_flattened[i_4457] = input_as_bytes[byte_index]; + let i_0: u32 = (offset * 32_u32) + byte_index; + hash_input_flattened[i_0] = input_as_bytes[byte_index]; } } } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/aes128_encrypt/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/aes128_encrypt/execute__tests__expanded.snap index 4b088fbd18f..d7524fa2af0 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/aes128_encrypt/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/aes128_encrypt/execute__tests__expanded.snap @@ -18,9 +18,8 @@ unconstrained fn decode_hex(s: str) -> [u8; M] { for i in 0_u32..N { if (i % 2_u32) != 0_u32 { continue; }; { - let i_4457: u32 = i / 2_u32; - result[i_4457] = - (decode_ascii(as_bytes[i]) * 16_u8) + decode_ascii(as_bytes[i + 1_u32]); + let i_0: u32 = i / 2_u32; + result[i_0] = (decode_ascii(as_bytes[i]) * 16_u8) + decode_ascii(as_bytes[i + 1_u32]); } } result diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_dedup_regression/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_dedup_regression/execute__tests__expanded.snap index 41d3108a3fb..9e6680a06f8 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/array_dedup_regression/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_dedup_regression/execute__tests__expanded.snap @@ -7,8 +7,8 @@ unconstrained fn main(x: u32) { for i in 0_u32..5_u32 { let mut a2: [Field; 5] = [1_Field, 2_Field, 3_Field, 4_Field, 5_Field]; { - let i_4444: u32 = x + i; - a2[i_4444] = 128_Field; + let i_0: u32 = x + i; + a2[i_0] = 128_Field; }; println(a2); if i != 0_u32 { diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_blackbox_input/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_blackbox_input/execute__tests__expanded.snap index 8bac42bd455..127a6f84f40 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_blackbox_input/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_blackbox_input/execute__tests__expanded.snap @@ -17,12 +17,12 @@ fn compute_root(leaf: [u8; 32], path: [u8; 64], _index: u32, root: [u8; 32]) { let b: u32 = if is_right { 0_u32 } else { 32_u32 }; for j in 0_u32..32_u32 { { - let i_4458: u32 = j + a; - hash_input[i_4458] = current[j]; + let i_0: u32 = j + a; + hash_input[i_0] = current[j]; }; { - let i_4459: u32 = j + b; - hash_input[i_4459] = path[offset + j]; + let i_1: u32 = j + b; + hash_input[i_1] = path[offset + j]; } } current = std::hash::blake3(hash_input); diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_nested_blackbox_input/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_nested_blackbox_input/execute__tests__expanded.snap index 64221d109e0..55d9b89058d 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_nested_blackbox_input/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_dynamic_nested_blackbox_input/execute__tests__expanded.snap @@ -14,13 +14,13 @@ struct Foo { fn main(mut x: [Foo; 3], y: pub u32, hash_result: pub [u8; 32]) { { - let i_4443: u32 = y - 1_u32; - x[i_4443].bar.inner = [106_u8, 107_u8, 10_u8]; + let i_0: u32 = y - 1_u32; + x[i_0].bar.inner = [106_u8, 107_u8, 10_u8]; }; let mut hash_input: [u8; 3] = x[y - 1_u32].bar.inner; { - let i_4445: u32 = y - 1_u32; - hash_input[i_4445] = 0_u8; + let i_1: u32 = y - 1_u32; + hash_input[i_1] = 0_u8; }; let hash: [u8; 32] = std::hash::blake3(hash_input); assert(hash == hash_result); diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow/execute__tests__expanded.snap index e266f3baa29..9a6566e9aaf 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow/execute__tests__expanded.snap @@ -22,8 +22,8 @@ fn modify_in_inlined_constrained(original: [Field; 5], index: u32) -> ExecutionR modified[index] = 27_Field; let modified_once: [Field; 5] = modified; { - let i_4455: u32 = index + 1_u32; - modified[i_4455] = 27_Field; + let i_0: u32 = index + 1_u32; + modified[i_0] = 27_Field; }; ExecutionResult { original: original, modified_once: modified_once, modified_twice: modified } } @@ -33,8 +33,8 @@ unconstrained fn modify_in_unconstrained(original: [Field; 5], index: u32) -> Ex modified[index] = 27_Field; let modified_once: [Field; 5] = modified; { - let i_4458: u32 = index + 1_u32; - modified[i_4458] = 27_Field; + let i_0: u32 = index + 1_u32; + modified[i_0] = 27_Field; }; ExecutionResult { original: original, modified_once: modified_once, modified_twice: modified } } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow_regression/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow_regression/execute__tests__expanded.snap index ca368912a11..189ba1f09f0 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow_regression/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/brillig_cow_regression/execute__tests__expanded.snap @@ -155,33 +155,33 @@ unconstrained fn main(kernel_data: DataToHash) -> pub [Field; 2] { let mut offset: u32 = 0_u32; for j in 0_u32..MAX_NOTE_HASHES_PER_TX { { - let i_4467: u32 = offset + j; - tx_effects_hash_inputs[i_4467] = new_note_hashes[j]; + let i_0: u32 = offset + j; + tx_effects_hash_inputs[i_0] = new_note_hashes[j]; } } offset = offset + MAX_NOTE_HASHES_PER_TX; for j in 0_u32..MAX_NULLIFIERS_PER_TX { { - let i_4469: u32 = offset + j; - tx_effects_hash_inputs[i_4469] = new_nullifiers[j]; + let i_1: u32 = offset + j; + tx_effects_hash_inputs[i_1] = new_nullifiers[j]; } } offset = offset + MAX_NULLIFIERS_PER_TX; for j in 0_u32..MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX { { - let i_4471: u32 = offset + (j * 2_u32); - tx_effects_hash_inputs[i_4471] = public_data_update_requests[j].leaf_slot; + let i_2: u32 = offset + (j * 2_u32); + tx_effects_hash_inputs[i_2] = public_data_update_requests[j].leaf_slot; }; { - let i_4472: u32 = (offset + (j * 2_u32)) + 1_u32; - tx_effects_hash_inputs[i_4472] = public_data_update_requests[j].new_value; + let i_3: u32 = (offset + (j * 2_u32)) + 1_u32; + tx_effects_hash_inputs[i_3] = public_data_update_requests[j].new_value; } } offset = offset + (MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2_u32); for j in 0_u32..MAX_L2_TO_L1_MSGS_PER_TX { { - let i_4474: u32 = offset + j; - tx_effects_hash_inputs[i_4474] = l2ToL1Msgs[j]; + let i_4: u32 = offset + j; + tx_effects_hash_inputs[i_4] = l2ToL1Msgs[j]; } } offset = offset + MAX_L2_TO_L1_MSGS_PER_TX; @@ -191,21 +191,21 @@ unconstrained fn main(kernel_data: DataToHash) -> pub [Field; 2] { let new_contracts: [NewContractData; 1] = kernel_data.new_contracts; tx_effects_hash_inputs[offset] = new_contracts[0_u32].contract_address; { - let i_4477: u32 = offset + 1_u32; - tx_effects_hash_inputs[i_4477] = new_contracts[0_u32].portal_contract_address; + let i_5: u32 = offset + 1_u32; + tx_effects_hash_inputs[i_5] = new_contracts[0_u32].portal_contract_address; }; offset = offset + (MAX_NEW_CONTRACTS_PER_TX * 2_u32); for j in 0_u32..NUM_FIELDS_PER_SHA256 { { - let i_4479: u32 = offset + j; - tx_effects_hash_inputs[i_4479] = encryptedLogsHash[j]; + let i_6: u32 = offset + j; + tx_effects_hash_inputs[i_6] = encryptedLogsHash[j]; } } offset = offset + (NUM_ENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256); for j in 0_u32..NUM_FIELDS_PER_SHA256 { { - let i_4481: u32 = offset + j; - tx_effects_hash_inputs[i_4481] = unencryptedLogsHash[j]; + let i_7: u32 = offset + j; + tx_effects_hash_inputs[i_7] = unencryptedLogsHash[j]; } } offset = offset + (NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256); @@ -215,8 +215,8 @@ unconstrained fn main(kernel_data: DataToHash) -> pub [Field; 2] { let input_as_bytes: [u8; 32] = tx_effects_hash_inputs[offset].to_be_bytes(); for byte_index in 0_u32..32_u32 { { - let i_4486: u32 = (offset * 32_u32) + byte_index; - hash_input_flattened[i_4486] = input_as_bytes[byte_index]; + let i_8: u32 = (offset * 32_u32) + byte_index; + hash_input_flattened[i_8] = input_as_bytes[byte_index]; } } } @@ -225,11 +225,9 @@ unconstrained fn main(kernel_data: DataToHash) -> pub [Field; 2] { tx_effects_hash_inputs[TX_EFFECT_HASH_FULL_FIELDS + log_field_index].to_be_bytes(); for byte_index in 0_u32..16_u32 { { - let i_4490: u32 = ( - (TX_EFFECT_HASH_FULL_FIELDS * 32_u32) + (log_field_index * 16_u32) - ) + let i_9: u32 = ((TX_EFFECT_HASH_FULL_FIELDS * 32_u32) + (log_field_index * 16_u32)) + byte_index; - hash_input_flattened[i_4490] = input_as_bytes[byte_index]; + hash_input_flattened[i_9] = input_as_bytes[byte_index]; } } } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/conditional_1/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/conditional_1/execute__tests__expanded.snap index 9368c56e99d..c1c6e1baf0c 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/conditional_1/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/conditional_1/execute__tests__expanded.snap @@ -27,8 +27,8 @@ fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]) { if i_u32 == a { for j in 0_u32..4_u32 { { - let i_4456: u32 = i + j; - data[i_4456] = c[(4_u32 - 1_u32) - j]; + let i_0: u32 = i + j; + data[i_0] = c[(4_u32 - 1_u32) - j]; }; for k in 0_u32..4_u32 { ba = ba + data[k]; diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/databus_two_calldata/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/databus_two_calldata/execute__tests__expanded.snap index fb452785f8a..c6c36598e06 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/databus_two_calldata/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/databus_two_calldata/execute__tests__expanded.snap @@ -9,8 +9,8 @@ fn main(mut x: [u32; 4], y: [u32; 3], z: [u32; 4]) -> return_data [u32; 4] { result[idx] = y[idx] + z[idx]; } { - let i_4446: u32 = x[3_u32]; - result[i_4446] = z[x[3_u32]]; + let i_0: u32 = x[3_u32]; + result[i_0] = z[x[3_u32]]; }; result } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/encrypted_log_regression/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/encrypted_log_regression/execute__tests__expanded.snap index 38afba63fe3..5f719e6222e 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/encrypted_log_regression/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/encrypted_log_regression/execute__tests__expanded.snap @@ -39,15 +39,15 @@ fn compute_encrypted_log( if flag { for i in 0_u32..EPH_PK_SIZE { { - let i_4459: u32 = offset + i; - encrypted_bytes[i_4459] = eph_pk_bytes[i]; + let i_0: u32 = offset + i; + encrypted_bytes[i_0] = eph_pk_bytes[i]; } } offset = offset + EPH_PK_SIZE; for i in 0_u32..HEADER_SIZE { { - let i_4461: u32 = offset + i; - encrypted_bytes[i_4461] = incoming_header_ciphertext[i]; + let i_1: u32 = offset + i; + encrypted_bytes[i_1] = incoming_header_ciphertext[i]; } } offset = offset + HEADER_SIZE; @@ -56,8 +56,8 @@ fn compute_encrypted_log( assert(size == incoming_body_ciphertext.len(), "ciphertext length mismatch"); for i in 0_u32..size { { - let i_4464: u32 = offset + i; - encrypted_bytes[i_4464] = incoming_body_ciphertext[i]; + let i_2: u32 = offset + i; + encrypted_bytes[i_2] = incoming_body_ciphertext[i]; } } }; diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_dynamic/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_dynamic/execute__tests__expanded.snap index 888d2f056dc..dda7bdb9c93 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_dynamic/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_dynamic/execute__tests__expanded.snap @@ -35,13 +35,13 @@ fn main(mut x: [Foo; 4], y: pub u32) { assert(x[3_u32].a == 50_Field); if y == 2_u32 { { - let i_4442: u32 = y - 1_u32; - x[i_4442].b = [50_Field, 51_Field, 52_Field]; + let i_0: u32 = y - 1_u32; + x[i_0].b = [50_Field, 51_Field, 52_Field]; } } else { { - let i_4443: u32 = y - 1_u32; - x[i_4443].b = [100_Field, 101_Field, 102_Field]; + let i_1: u32 = y - 1_u32; + x[i_1].b = [100_Field, 101_Field, 102_Field]; } }; assert(x[2_u32].b == [100_Field, 101_Field, 102_Field]); @@ -60,39 +60,39 @@ fn main(mut x: [Foo; 4], y: pub u32) { assert(foo_parents[1_u32].foos[1_u32].b == [5_Field, 6_Field, 21_Field]); if y == 2_u32 { { - let i_4447: u32 = y - 2_u32; - let i_4448: u32 = y - 2_u32; - foo_parents[i_4447].foos[i_4448].b = [10_Field, 9_Field, 8_Field]; + let i_2: u32 = y - 2_u32; + let i_3: u32 = y - 2_u32; + foo_parents[i_2].foos[i_3].b = [10_Field, 9_Field, 8_Field]; } } else { { - let i_4449: u32 = y - 2_u32; - let i_4450: u32 = y - 2_u32; - foo_parents[i_4449].foos[i_4450].b = [20_Field, 19_Field, 18_Field]; + let i_4: u32 = y - 2_u32; + let i_5: u32 = y - 2_u32; + foo_parents[i_4].foos[i_5].b = [20_Field, 19_Field, 18_Field]; } }; assert(foo_parents[1_u32].foos[1_u32].b == [20_Field, 19_Field, 18_Field]); assert(foo_parents[1_u32].foos[1_u32].b[2_u32] == 18_Field); if y == 3_u32 { { - let i_4451: u32 = y - 2_u32; - let i_4452: u32 = y - 2_u32; - let i_4453: u32 = y - 1_u32; - foo_parents[i_4451].foos[i_4452].b[i_4453] = 5000_Field; + let i_6: u32 = y - 2_u32; + let i_7: u32 = y - 2_u32; + let i_8: u32 = y - 1_u32; + foo_parents[i_6].foos[i_7].b[i_8] = 5000_Field; } } else { { - let i_4454: u32 = y - 2_u32; - let i_4455: u32 = y - 2_u32; - let i_4456: u32 = y - 1_u32; - foo_parents[i_4454].foos[i_4455].b[i_4456] = 1000_Field; + let i_9: u32 = y - 2_u32; + let i_10: u32 = y - 2_u32; + let i_11: u32 = y - 1_u32; + foo_parents[i_9].foos[i_10].b[i_11] = 1000_Field; } }; assert(foo_parents[1_u32].foos[1_u32].b[2_u32] == 5000_Field); { - let i_4457: u32 = y - 2_u32; - let i_4458: u32 = y - 3_u32; - foo_parents[i_4457].foos[i_4458].b = foo_parents[y - 2_u32].foos[y - 2_u32].b; + let i_12: u32 = y - 2_u32; + let i_13: u32 = y - 3_u32; + foo_parents[i_12].foos[i_13].b = foo_parents[y - 2_u32].foos[y - 2_u32].b; }; assert(foo_parents[1_u32].foos[0_u32].b == [20_Field, 19_Field, 5000_Field]); } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_in_vector/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_in_vector/execute__tests__expanded.snap index b8077d05d82..c23aa920c5e 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_in_vector/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/nested_array_in_vector/execute__tests__expanded.snap @@ -48,25 +48,25 @@ fn main(y: u32) { assert(x[y].bar.inner == [109_Field, 110_Field, 111_Field]); if y != 2_u32 { { - let i_4446: u32 = y - 2_u32; - x[i_4446].a = 50_Field; + let i_0: u32 = y - 2_u32; + x[i_0].a = 50_Field; } } else { { - let i_4447: u32 = y - 2_u32; - x[i_4447].a = 100_Field; + let i_1: u32 = y - 2_u32; + x[i_1].a = 100_Field; } }; assert(x[y - 2_u32].a == 50_Field); if y == 2_u32 { { - let i_4448: u32 = y - 1_u32; - x[i_4448].b = [50_Field, 51_Field, 52_Field]; + let i_2: u32 = y - 1_u32; + x[i_2].b = [50_Field, 51_Field, 52_Field]; } } else { { - let i_4449: u32 = y - 1_u32; - x[i_4449].b = [100_Field, 101_Field, 102_Field]; + let i_3: u32 = y - 1_u32; + x[i_3].b = [100_Field, 101_Field, 102_Field]; } }; assert(x[2_u32].b == [100_Field, 101_Field, 102_Field]); diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_1144_1169_2399_6609/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_1144_1169_2399_6609/execute__tests__expanded.snap index 1f44f011474..7f7f0dd2e7d 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/regression_1144_1169_2399_6609/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_1144_1169_2399_6609/execute__tests__expanded.snap @@ -36,12 +36,12 @@ fn compact_decode(input: [u8; N], length: Field) -> ([U4; 16], Field if (i as u32) < (length as u32) { let x: u8 = input[i]; { - let i_4468: u32 = (2_u32 * i) - 1_u32; - nibble[i_4468] = U4::from_u8(x >> 4_u8); + let i_0: u32 = (2_u32 * i) - 1_u32; + nibble[i_0] = U4::from_u8(x >> 4_u8); }; { - let i_4469: u32 = 2_u32 * i; - nibble[i_4469] = U4::from_u8(x & 15_u8); + let i_1: u32 = 2_u32 * i; + nibble[i_1] = U4::from_u8(x & 15_u8); } } } @@ -50,12 +50,12 @@ fn compact_decode(input: [u8; N], length: Field) -> ([U4; 16], Field if (i as u32) < ((length as u32) - 1_u32) { let x: u8 = input[i + 1_u32]; { - let i_4472: u32 = 2_u32 * i; - nibble[i_4472] = U4::from_u8(x >> 4_u8); + let i_2: u32 = 2_u32 * i; + nibble[i_2] = U4::from_u8(x >> 4_u8); }; { - let i_4473: u32 = (2_u32 * i) + 1_u32; - nibble[i_4473] = U4::from_u8(x & 15_u8); + let i_3: u32 = (2_u32 * i) + 1_u32; + nibble[i_3] = U4::from_u8(x & 15_u8); } } } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_1/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_1/execute__tests__expanded.snap index de9c0f0d090..87fe57239ff 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_1/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_1/execute__tests__expanded.snap @@ -16,8 +16,8 @@ impl BoundedVec4 { pub fn push(&mut self, elem: Field) { { - let i_4462: u32 = self.len; - self.storage[i_4462] = elem; + let i_0: u32 = self.len; + self.storage[i_0] = elem; }; self.len = self.len + 1_u32; } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_2/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_2/execute__tests__expanded.snap index 0676cd67702..d1bf2a84095 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_2/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_6674_2/execute__tests__expanded.snap @@ -16,8 +16,8 @@ impl BoundedVec4 { pub fn push(&mut self, elem: Field) { { - let i_4462: u32 = self.len; - self.storage[i_4462] = elem; + let i_0: u32 = self.len; + self.storage[i_0] = elem; }; self.len = self.len + 1_u32; } diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_capacity_tracker/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_capacity_tracker/execute__tests__expanded.snap index d60b128c6a5..3187ef25290 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/regression_capacity_tracker/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_capacity_tracker/execute__tests__expanded.snap @@ -8,13 +8,13 @@ fn main(expected: pub Field, first: Field, input: [Field; 20]) { assert(hasher_vector[0_u32] == expected); if (expected as u32) > 10_u32 { { - let i_4444: u32 = (expected - 10_Field) as u32; - hasher_vector[i_4444] = 100_Field; + let i_0: u32 = (expected - 10_Field) as u32; + hasher_vector[i_0] = 100_Field; } } else { { - let i_4445: u32 = expected as u32; - hasher_vector[i_4445] = 100_Field; + let i_1: u32 = expected as u32; + hasher_vector[i_1] = 100_Field; } }; assert(hasher_vector[0_u32] == expected); diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_index/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_index/execute__tests__expanded.snap index 22df491a59a..203c9346a22 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_index/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_index/execute__tests__expanded.snap @@ -36,8 +36,8 @@ fn dynamic_vector_index_set_if(mut vector: [Field], x: u32, y: u32) { assert(vector[x] == 4_Field); vector[x] = vector[x] - 2_Field; { - let i_4488: u32 = x - 1_u32; - vector[i_4488] = vector[x]; + let i_0: u32 = x - 1_u32; + vector[i_0] = vector[x]; } } else { vector[x] = 0_Field; @@ -56,8 +56,8 @@ fn dynamic_vector_index_set_else(mut vector: [Field], x: u32, y: u32) { assert(vector[x] == 4_Field); vector[x] = vector[x] - 2_Field; { - let i_4489: u32 = x - 1_u32; - vector[i_4489] = vector[x]; + let i_0: u32 = x - 1_u32; + vector[i_0] = vector[x]; } } else { vector[x] = 0_Field; diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_insert/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_insert/execute__tests__expanded.snap index 61ac6c8b221..4cc9e01b94b 100644 --- a/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_insert/execute__tests__expanded.snap +++ b/tooling/nargo_cli/tests/snapshots/execution_success/vector_dynamic_insert/execute__tests__expanded.snap @@ -21,8 +21,8 @@ fn insert(x: u32, array: [Field; 5]) { fn insert_dynamic_array(x: u32, array: [Field; 5]) { let mut value_to_insert: [Field; 5] = array; { - let i_4452: u32 = x - 1_u32; - value_to_insert[i_4452] = 10_Field; + let i_0: u32 = x - 1_u32; + value_to_insert[i_0] = 10_Field; }; let mut vector: [[Field; 5]] = [array, array, array].as_vector(); vector = vector.insert(x - 3_u32, value_to_insert);