diff --git a/naga/src/proc/index.rs b/naga/src/proc/index.rs index 1066eb238..810f42e41 100644 --- a/naga/src/proc/index.rs +++ b/naga/src/proc/index.rs @@ -340,12 +340,21 @@ impl GuardedIndex { module: &crate::Module, ) { if let GuardedIndex::Expression(expr) = *self { - if let Ok(value) = module - .to_ctx() - .eval_expr_to_u32_from(expr, &function.expressions) - { - *self = GuardedIndex::Known(value); - } + *self = GuardedIndex::from_expression(expr, function, module); + } + } + + pub(crate) fn from_expression( + expr: Handle, + function: &crate::Function, + module: &crate::Module, + ) -> Self { + match module + .to_ctx() + .eval_expr_to_u32_from(expr, &function.expressions) + { + Ok(value) => Self::Known(value), + Err(_) => Self::Expression(expr), } } }