Skip to content

Commit

Permalink
fix array being flagged as constructible when its base isn't
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Jan 25, 2023
1 parent 85e3b08 commit 3ace8b8
Show file tree
Hide file tree
Showing 12 changed files with 8,921 additions and 471 deletions.
14 changes: 9 additions & 5 deletions src/valid/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl super::Validator {
Err(e) => Err(e),
};

let sized_flag = match size {
let type_info_mask = match size {
crate::ArraySize::Constant(const_handle) => {
let constant = &constants[const_handle];
let length_is_positive = match *constant {
Expand Down Expand Up @@ -455,19 +455,23 @@ impl super::Validator {
return Err(TypeError::NonPositiveArrayLength(const_handle));
}

TypeFlags::SIZED | TypeFlags::ARGUMENT | TypeFlags::CONSTRUCTIBLE
TypeFlags::DATA
| TypeFlags::SIZED
| TypeFlags::COPY
| TypeFlags::HOST_SHAREABLE
| TypeFlags::ARGUMENT
| TypeFlags::CONSTRUCTIBLE
}
crate::ArraySize::Dynamic => {
// Non-SIZED types may only appear as the last element of a structure.
// This is enforced by checks for SIZED-ness for all compound types,
// and a special case for structs.
TypeFlags::empty()
TypeFlags::DATA | TypeFlags::COPY | TypeFlags::HOST_SHAREABLE
}
};

let base_mask = TypeFlags::COPY | TypeFlags::HOST_SHAREABLE;
TypeInfo {
flags: TypeFlags::DATA | (base_info.flags & base_mask) | sized_flag,
flags: base_info.flags & type_info_mask,
uniform_layout,
storage_layout,
}
Expand Down
1 change: 1 addition & 0 deletions tests/in/access.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct Bar {
_matrix: mat4x3<f32>,
matrix_array: array<mat2x2<f32>, 2>,
atom: atomic<i32>,
atom_arr: array<atomic<i32>, 10>,
arr: array<vec2<u32>, 2>,
data: array<AlignedWrapper>,
}
Expand Down
Loading

0 comments on commit 3ace8b8

Please sign in to comment.