diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 9d2055ff6a..c3d5bd39b7 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -146,15 +146,17 @@ impl ConstantEvaluator<'_> { Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { Ok(self.register_evaluated_expr(expr.clone(), span)) } - Expression::Compose { ref components, .. } => { - for component in components { - self.check_and_get(*component)?; - } - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Compose { ty, ref components } => { + let components = components + .iter() + .map(|component| self.check_and_get(*component)) + .collect::, _>>()?; + + Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) } - Expression::Splat { value, .. } => { - self.check_and_get(value)?; - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Splat { value, size } => { + let value = self.check_and_get(value)?; + Ok(self.register_evaluated_expr(Expression::Splat { value, size }, span)) } Expression::AccessIndex { base, index } => { let base = self.check_and_get(base)?; diff --git a/tests/out/wgsl/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index bad1b1ec50..882b5968c2 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -10,7 +10,7 @@ var Texture: texture_2d; var Sampler: sampler; fn returns() -> S { - return S(Value); + return S(1); } fn statement() {