mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
[wgsl-in]: Correctly compare pointer types.
Treat `TypeInner::ValuePointer` and `TypeInner::Pointer` as equivalent by converting them to a canonical form before comparison. Support `ValuePointer` in WGSL type output. Fixes #1318.
This commit is contained in:
1 parent
6e4401ae96
commit
f3ea2130a4
6 files changed
+148
-9
No files matched your search
+13
-2
@@ -243,7 +243,8 @@ impl super::Validator {
|
||||
let ty = context
|
||||
.resolve_type_impl(expr, &self.valid_expression_set)
|
||||
.map_err(|error| CallError::Argument { index, error })?;
|
||||
if ty != &context.types[arg.ty].inner {
|
||||
let arg_inner = &context.types[arg.ty].inner;
|
||||
if !ty.equivalent(arg_inner, context.types) {
|
||||
return Err(CallError::ArgumentType {
|
||||
index,
|
||||
required: arg.ty,
|
||||
@@ -448,7 +449,17 @@ impl super::Validator {
|
||||
.map(|expr| context.resolve_type(expr, &self.valid_expression_set))
|
||||
.transpose()?;
|
||||
let expected_ty = context.return_type.map(|ty| &context.types[ty].inner);
|
||||
if value_ty != expected_ty {
|
||||
// We can't return pointers, but it seems best not to embed that
|
||||
// assumption here, so use `TypeInner::equivalent` for comparison.
|
||||
let okay = match (value_ty, expected_ty) {
|
||||
(None, None) => true,
|
||||
(Some(value_inner), Some(expected_inner)) => {
|
||||
value_inner.equivalent(expected_inner, context.types)
|
||||
}
|
||||
(_, _) => false,
|
||||
};
|
||||
|
||||
if !okay {
|
||||
log::error!(
|
||||
"Returning {:?} where {:?} is expected",
|
||||
value_ty,
|
||||
|
||||
Reference in new issue
Block a user