From 19120492b9c45a202e88ef62a8812aaca91f73d1 Mon Sep 17 00:00:00 2001 From: sofia Date: Sat, 26 Jul 2025 01:02:25 +0300 Subject: [PATCH] Update get_type to accept imported types as well --- reid/src/mir/pass.rs | 9 +++++++++ reid/src/mir/typecheck/mod.rs | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/reid/src/mir/pass.rs b/reid/src/mir/pass.rs index e13ad49..8c5ab5d 100644 --- a/reid/src/mir/pass.rs +++ b/reid/src/mir/pass.rs @@ -156,6 +156,15 @@ impl Scope { .find(|(CustomTypeKey(n, _), _)| n == name) .map(|(key, _)| key) } + + pub fn get_type(&self, typekey: &CustomTypeKey) -> Option<&TypeDefinition> { + self.types.get(&typekey).or(self + .types + .0 + .iter() + .find(|(key, def)| key.0 == typekey.0 && def.importer == Some(typekey.1)) + .map(|(_, v)| v)) + } } #[derive(Clone, Debug)] diff --git a/reid/src/mir/typecheck/mod.rs b/reid/src/mir/typecheck/mod.rs index 38dbe6f..f4ee267 100644 --- a/reid/src/mir/typecheck/mod.rs +++ b/reid/src/mir/typecheck/mod.rs @@ -300,8 +300,7 @@ impl TypeKind { TypeKind::CustomType(custom_type_key) => { state .scope - .types - .get(custom_type_key) + .get_type(custom_type_key) .map(|_| ()) .ok_or(ErrorKind::NoSuchType( custom_type_key.0.clone(),