From 4e85a21d2c6431865d4e398f284295212f017af9 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 17 Sep 2023 17:50:06 -0700 Subject: [PATCH] ConstantEvaluator: Don't ignore the return value of check_and_get. --- src/proc/constant_evaluator.rs | 18 ++++++++++-------- tests/out/wgsl/module-scope.wgsl | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) 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() {