From 130d99125a09110a3ee3e877d88d83b5aa37f369 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:33:07 +0000 Subject: [PATCH] fix: prevent panic within `remove_possibly_mutated_cached_make_arrays` (#7264) --- compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index 1a424c37050..8d847ca103b 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -725,6 +725,11 @@ impl<'brillig> Context<'brillig> { // Should we consider calls to slice_push_back and similar to be mutating operations as well? if let Store { value: array, .. } | ArraySet { array, .. } = instruction { + if function.dfg.is_global(*array) { + // Early return as we expect globals to be immutable. + return; + }; + let instruction = match &function.dfg[*array] { Value::Instruction { instruction, .. } => &function.dfg[*instruction], _ => return,