diag(naga): add type info to InvalidBinaryOperandTypes

This commit is contained in:
Erich Gubler 2024-10-22 10:04:27 -04:00
parent 2a2655def8
commit e8a8281203
2 changed files with 20 additions and 5 deletions

View File

@ -106,6 +106,10 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
### Changes ### 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 #### General
- Make `Surface::as_hal` take an immutable reference to the surface. By @jerzywilczek in [#9999](https://github.com/gfx-rs/wgpu/pull/9999) - Make `Surface::as_hal` take an immutable reference to the surface. By @jerzywilczek in [#9999](https://github.com/gfx-rs/wgpu/pull/9999)

View File

@ -39,11 +39,20 @@ pub enum ExpressionError {
IndexableLength(#[from] IndexableLengthError), IndexableLength(#[from] IndexableLengthError),
#[error("Operation {0:?} can't work with {1:?}")] #[error("Operation {0:?} can't work with {1:?}")]
InvalidUnaryOperandType(crate::UnaryOperator, Handle<crate::Expression>), InvalidUnaryOperandType(crate::UnaryOperator, Handle<crate::Expression>),
#[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 { InvalidBinaryOperandTypes {
op: crate::BinaryOperator, op: crate::BinaryOperator,
lhs: Handle<crate::Expression>, lhs_expr: Handle<crate::Expression>,
rhs: Handle<crate::Expression>, lhs_type: crate::TypeInner,
rhs_expr: Handle<crate::Expression>,
rhs_type: crate::TypeInner,
}, },
#[error("Selecting is not possible")] #[error("Selecting is not possible")]
InvalidSelectTypes, InvalidSelectTypes,
@ -849,8 +858,10 @@ impl super::Validator {
); );
return Err(ExpressionError::InvalidBinaryOperandTypes { return Err(ExpressionError::InvalidBinaryOperandTypes {
op, op,
lhs: left, lhs_expr: left,
rhs: right, lhs_type: left_inner.clone(),
rhs_expr: right,
rhs_type: right_inner.clone(),
}); });
} }
ShaderStages::all() ShaderStages::all()