diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index af4ffde859..ea7af7a1eb 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -57,7 +57,8 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { (true, true) => Box::new(from..=to), (true, false) => Box::new(from..to), (false, true) => Box::new((to..=from).rev()), - (false, false) => Box::new((to..from).rev()), + // add the range to the values to get correct bound + (false, false) => Box::new(((to + 1)..(from + 1)).rev()), }; for i in iter { diff --git a/tests/compiler/statements/all_loops.leo b/tests/compiler/statements/all_loops.leo index 994d0f8264..d8128513d5 100644 --- a/tests/compiler/statements/all_loops.leo +++ b/tests/compiler/statements/all_loops.leo @@ -6,7 +6,7 @@ input_file: inputs/dummy.in function main(k: bool) -> bool { let reverse: u32 = 0; - for i in 10..0 { + for i in 9..0 { reverse += i; } diff --git a/tests/expectations/compiler/compiler/statements/all_loops.leo.out b/tests/expectations/compiler/compiler/statements/all_loops.leo.out index ead54a1743..392b2542c0 100644 --- a/tests/expectations/compiler/compiler/statements/all_loops.leo.out +++ b/tests/expectations/compiler/compiler/statements/all_loops.leo.out @@ -16,6 +16,6 @@ outputs: r0: type: bool value: "true" - initial_ast: 7ecd56e44c6b1cb4f702a2712a2a7fe3bf564dac26a70e1f14151a688fb24769 - canonicalized_ast: 360ecac21f95b0e1d949d49458f2c4557446d01db08333d6f25621ef47a78a66 - type_inferenced_ast: 853fdefe080011aaa35363e827a527ab7ce6c7e93cd568c8a150211fa6e402fe + initial_ast: 280277fb32e4eece0eab1f72338a9b60b6792d7f11124e8c4a5678ef3fc4a04e + canonicalized_ast: 84769d3580d79825fef6fd00dd9ab88dc6eaf16bf2e3f3c46feae654f8f1f746 + type_inferenced_ast: 078070bc5df73c49f8de0ca37ac624c93a67551e0221dc1c65a84588507a2a6f