mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
Forbid returning pointers and atomics from functions.
Introduce a new `TypeFlags::CONSTRUCTIBLE` flag, corresponding to WGSL's "constructible types". Set this on the appropriate types. Check for this flag on function return types.
This commit is contained in:
1 parent
1c21fc02fe
commit
89bed99bcc
3 files changed
+66
-3
No files matched your search
@@ -86,6 +86,8 @@ pub enum FunctionError {
|
||||
},
|
||||
#[error("Argument '{name}' at index {index} has a type that can't be passed into functions.")]
|
||||
InvalidArgumentType { index: usize, name: String },
|
||||
#[error("The function's given return type cannot be returned from functions")]
|
||||
NonConstructibleReturnType,
|
||||
#[error("Argument '{name}' at index {index} is a pointer of space {space:?}, which can't be passed into functions.")]
|
||||
InvalidArgumentPointerSpace {
|
||||
index: usize,
|
||||
@@ -894,6 +896,17 @@ impl super::Validator {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validate")]
|
||||
if let Some(ref result) = fun.result {
|
||||
if !self.types[result.ty.index()]
|
||||
.flags
|
||||
.contains(super::TypeFlags::CONSTRUCTIBLE)
|
||||
{
|
||||
return Err(FunctionError::NonConstructibleReturnType
|
||||
.with_span_handle(result.ty, &module.types));
|
||||
}
|
||||
}
|
||||
|
||||
self.valid_expression_set.clear();
|
||||
self.valid_expression_list.clear();
|
||||
for (handle, expr) in fun.expressions.iter() {
|
||||
|
||||
Reference in new issue
Block a user