From 5e68a631510d081e5e906e21e5747f284e3114ac Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 12 Nov 2024 07:44:02 -0500 Subject: [PATCH] fix(const_eval): don't panic when a `vecN` constructor's arg. count is less than N (#6508) --- CHANGELOG.md | 1 + naga/src/proc/constant_evaluator.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f24b1aa1a..40245b55e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ Bottom level categories: #### Naga - Fix crash when a texture argument is missing. By @aedm in [#6486](https://github.com/gfx-rs/wgpu/pull/6486) +- Emit an error in constant evaluation, rather than crash, in certain cases where `vecN` constructors have less than N arguments. By @ErichDonGubler in [#6508](https://github.com/gfx-rs/wgpu/pull/6508). #### General diff --git a/naga/src/proc/constant_evaluator.rs b/naga/src/proc/constant_evaluator.rs index 5fdf48151..c12983c0c 100644 --- a/naga/src/proc/constant_evaluator.rs +++ b/naga/src/proc/constant_evaluator.rs @@ -137,8 +137,8 @@ macro_rules! gen_component_wise_extractor { for idx in 0..(size as u8).into() { let group = component_groups .iter() - .map(|cs| cs[idx]) - .collect::>() + .map(|cs| cs.get(idx).cloned().ok_or(err.clone())) + .collect::, _>>()? .into_inner() .unwrap(); new_components.push($ident(