Skip to content

Commit 524bd2b

Browse files
committed
fix(naga): Fix const evaluation on bool
1 parent 81eca17 commit 524bd2b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

naga/src/proc/constant_evaluator.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,19 @@ impl<'a> ConstantEvaluator<'a> {
26962696
return Err(ConstantEvaluatorError::InvalidBinaryOpArgs);
26972697
}
26982698

2699+
if matches!(
2700+
(left_value, op),
2701+
(
2702+
Literal::Bool(_),
2703+
BinaryOperator::Less
2704+
| BinaryOperator::LessEqual
2705+
| BinaryOperator::Greater
2706+
| BinaryOperator::GreaterEqual
2707+
)
2708+
) {
2709+
return Err(ConstantEvaluatorError::InvalidBinaryOpArgs);
2710+
}
2711+
26992712
let literal = match op {
27002713
BinaryOperator::Equal => Literal::Bool(left_value == right_value),
27012714
BinaryOperator::NotEqual => Literal::Bool(left_value != right_value),
@@ -2849,6 +2862,8 @@ impl<'a> ConstantEvaluator<'a> {
28492862
(Literal::Bool(a), Literal::Bool(b)) => Literal::Bool(match op {
28502863
BinaryOperator::LogicalAnd => a && b,
28512864
BinaryOperator::LogicalOr => a || b,
2865+
BinaryOperator::And => a & b,
2866+
BinaryOperator::InclusiveOr => a | b,
28522867
_ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs),
28532868
}),
28542869
_ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs),

0 commit comments

Comments
 (0)