From cc4ab13fabbe8bb2653f3e6c96f52ac7e898eb4f Mon Sep 17 00:00:00 2001 From: Kotha Dhakshin <179742818+Dhakshin2007@users.noreply.github.com> Date: Fri, 3 Apr 2026 10:20:16 +0530 Subject: [PATCH] fix(ir/validator): validate non-struct type in Access/ExtractStructField + fix typo Two fixes in validator.rs: 1. BUG FIX (logic): validate_struct_field_in_bounds() silently ignored Access/ExtractStructField opcodes when the resolved type was not a struct. Added an else-if branch so that using these opcodes on a non-struct type is now correctly reported as an IR error. 2. fix typo: 'retintroduce' -> 'reintroduce' in TODO comment --- src/compiler/translator/ir/src/validator.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/translator/ir/src/validator.rs b/src/compiler/translator/ir/src/validator.rs index c1d0b3a0ad5..50071c27036 100644 --- a/src/compiler/translator/ir/src/validator.rs +++ b/src/compiler/translator/ir/src/validator.rs @@ -39,7 +39,7 @@ // look up and checking that !is_dead_code_eliminated // - If there's a cached "has side effect", that it's correct. // - No operations should have entirely constant arguments, that should be folded (and -// transformations shouldn't retintroduce it) +// transformations shouldn't reintroduce it) // - Catch misuse of built-in names. // - Precision is not applied to types that don't are not applicable. It _is_ applied to types // that are applicable (including uniforms and samplers for example). Needs to work to make @@ -408,7 +408,7 @@ impl<'a> Validator<'a> { for variable in &block.variables { if variable.id >= self.max_variable_count { self.on_error(format_args!( - "invalid variable id {} found in block variabls", + "invalid variable id {} found in block variables", variable.id )); } @@ -1557,6 +1557,13 @@ impl<'a> Validator<'a> { that is out of bounds", struct_type, field_index )); + } else if let Some(non_struct_type) = struct_type + && !matches!(non_struct_type, Type::Struct(_, _, _)) + { + self.on_error(format_args!( + "OpCode::Access/ExtractStructField expects a struct type, got {:?}", + non_struct_type + )); } }