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,