From 822c835179609de4ae76f9adcf6966ce9cf04da2 Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Mon, 16 Oct 2023 15:59:07 -0400 Subject: [PATCH] debug_printf: simple validation of debugPrintf arguments --- src/valid/function.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/valid/function.rs b/src/valid/function.rs index a55f57b6cd..6c732a7655 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -139,6 +139,11 @@ pub enum FunctionError { InvalidRayDescriptor(Handle), #[error("Ray Query {0:?} does not have a matching type")] InvalidRayQueryType(Handle), + #[error("Printf value argument {index} expression is invalid")] + InvalidPrintfArgument { + index: usize, + source: ExpressionError, + }, #[error( "Required uniformity of control flow for {0:?} in {1:?} is not fulfilled because of {2:?}" )] @@ -919,8 +924,15 @@ impl super::Validator { crate::RayQueryFunction::Terminate => {} } } - S::DebugPrintf { .. } => { - // FIXME + S::DebugPrintf { ref arguments, .. } => { + for (index, &expr) in arguments.iter().enumerate() { + context + .resolve_type_impl(expr, &self.valid_expression_set) + .map_err_inner(|source| { + FunctionError::InvalidPrintfArgument { index, source } + .with_span_handle(expr, context.expressions) + })?; + } } } }