Skip to content

Commit

Permalink
ConstantEvaluator: Don't ignore the return value of check_and_get.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Sep 20, 2023
1 parent 7ca5d3f commit 4e85a21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/proc/constant_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Result<Vec<_>, _>>()?;

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)?;
Expand Down
2 changes: 1 addition & 1 deletion tests/out/wgsl/module-scope.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Texture: texture_2d<f32>;
var Sampler: sampler;

fn returns() -> S {
return S(Value);
return S(1);
}

fn statement() {
Expand Down

0 comments on commit 4e85a21

Please sign in to comment.