From 679656f9e1c138cdec1cc20afb93e5d4591c2136 Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 11 Jun 2024 15:17:02 +0800 Subject: [PATCH] core/classes: Fix incorrect field locations for lists --- nac3core/src/codegen/classes.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nac3core/src/codegen/classes.rs b/nac3core/src/codegen/classes.rs index e78ea4a3..7eefd74d 100644 --- a/nac3core/src/codegen/classes.rs +++ b/nac3core/src/codegen/classes.rs @@ -541,18 +541,20 @@ impl<'ctx> ListType<'ctx> { self.as_base_type() .get_element_type() .into_struct_type() - .get_field_type_at_index(0) + .get_field_type_at_index(1) .map(BasicTypeEnum::into_int_type) .unwrap() } /// Returns the element type of this `list` type. #[must_use] - pub fn element_type(&self) -> BasicTypeEnum<'ctx> { + pub fn element_type(&self) -> AnyTypeEnum<'ctx> { self.as_base_type() .get_element_type() .into_struct_type() - .get_field_type_at_index(1) + .get_field_type_at_index(0) + .map(BasicTypeEnum::into_pointer_type) + .map(PointerType::get_element_type) .unwrap() } }