Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ impl Loop {
pub(super) fn get_const_upper_bound(&self, function: &Function) -> Option<FieldElement> {
let block = &function.dfg[self.header];
let instructions = block.instructions();
if instructions.is_empty() {
// If the loop condition is constant time, the loop header will be
// simplified to a simple jump.
return None;
}
assert_eq!(
instructions.len(),
1,
Expand Down
6 changes: 6 additions & 0 deletions test_programs/execution_success/regression_6734/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_6734"
type = "bin"
authors = [""]

[dependencies]
24 changes: 24 additions & 0 deletions test_programs/execution_success/regression_6734/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://github.com/noir-lang/noir/issues/6734

pub fn sub_array_extended<let SRC_LEN: u32, let DST_LEN: u32>(
src: [Field; SRC_LEN],
offset: u32,
) -> [Field; DST_LEN] {
let available_elements_to_copy = SRC_LEN - offset;
let elements_to_copy = if DST_LEN > available_elements_to_copy {
available_elements_to_copy
} else {
DST_LEN
};

let mut dst: [Field; DST_LEN] = std::mem::zeroed();
for i in 0..elements_to_copy {
dst[i] = src[i + offset];
}

dst
}

unconstrained fn main() {
assert_eq(sub_array_extended([], 0), []);
}