From 0b86b3a67f0c3221fc49859856b33f8773b587a7 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:38:55 +0000 Subject: [PATCH] chore: use `get_last_condition` in `link_condition` --- compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index e4949e54f75..6cadc1b11c4 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -390,9 +390,8 @@ impl<'f> Context<'f> { /// it is 'AND-ed' with the previous condition (if any) fn link_condition(&mut self, condition: ValueId) -> ValueId { // Retrieve the previous condition - if let Some(context) = self.condition_stack.last() { - let previous_branch = context.else_branch.as_ref().unwrap_or(&context.then_branch); - let and = Instruction::binary(BinaryOp::And, previous_branch.condition, condition); + if let Some(last_condition) = self.get_last_condition() { + let and = Instruction::binary(BinaryOp::And, last_condition, condition); let call_stack = self.inserter.function.dfg.get_value_call_stack_id(condition); self.insert_instruction(and, call_stack) } else {