Skip to content

Commit 27b83fc

Browse files
WIP: diag: render mismatched types in LocalVariableError::InitializerType
1 parent bbff2c4 commit 27b83fc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

naga/src/valid/function.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ pub enum SubgroupError {
8080
pub enum LocalVariableError {
8181
#[error("Local variable has a type {0:?} that can't be stored in a local variable.")]
8282
InvalidType(Handle<crate::Type>),
83-
#[error("Initializer doesn't match the variable type")]
84-
InitializerType,
83+
#[error(
84+
"Initializer of type {:?} doesn't match the variable type {:?}",
85+
initializer_ty,
86+
variable_ty
87+
)]
88+
InitializerType {
89+
variable_ty: crate::TypeInner,
90+
initializer_ty: crate::TypeInner,
91+
},
8592
#[error("Initializer is not a const or override expression")]
8693
NonConstOrOverrideInitializer,
8794
}
@@ -1652,7 +1659,10 @@ impl super::Validator {
16521659

16531660
if let Some(init) = var.init {
16541661
if !gctx.compare_types(&TypeResolution::Handle(var.ty), &fun_info[init].ty) {
1655-
return Err(LocalVariableError::InitializerType);
1662+
return Err(LocalVariableError::InitializerType {
1663+
initializer_ty: init_ty.clone(),
1664+
variable_ty: decl_ty.clone(),
1665+
});
16561666
}
16571667

16581668
if !local_expr_kind.is_const_or_override(init) {

0 commit comments

Comments
 (0)