diff --git a/CHANGELOG.md b/CHANGELOG.md index afaa5737a..f7ebcef42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,10 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148] ### Changes +#### Naga + +- Show types of LHS and RHS in binary operation type mismatch errors. By @ErichDonGubler in [#6450](https://github.com/gfx-rs/wgpu/pull/6450). + #### General - Make `Surface::as_hal` take an immutable reference to the surface. By @jerzywilczek in [#9999](https://github.com/gfx-rs/wgpu/pull/9999) diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index bf44e8608..9a1503401 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -39,11 +39,20 @@ pub enum ExpressionError { IndexableLength(#[from] IndexableLengthError), #[error("Operation {0:?} can't work with {1:?}")] InvalidUnaryOperandType(crate::UnaryOperator, Handle), - #[error("Operation {op:?} can't work with {lhs:?} and {rhs:?}")] + #[error( + "Operation {:?} can't work with {:?} (of type {:?}) and {:?} (of type {:?})", + op, + lhs_expr, + lhs_type, + rhs_expr, + rhs_type + )] InvalidBinaryOperandTypes { op: crate::BinaryOperator, - lhs: Handle, - rhs: Handle, + lhs_expr: Handle, + lhs_type: crate::TypeInner, + rhs_expr: Handle, + rhs_type: crate::TypeInner, }, #[error("Selecting is not possible")] InvalidSelectTypes, @@ -849,8 +858,10 @@ impl super::Validator { ); return Err(ExpressionError::InvalidBinaryOperandTypes { op, - lhs: left, - rhs: right, + lhs_expr: left, + lhs_type: left_inner.clone(), + rhs_expr: right, + rhs_type: right_inner.clone(), }); } ShaderStages::all()