Update get_type to accept imported types as well

This commit is contained in:
Sofia 2025-07-26 01:02:25 +03:00
parent 269de327b8
commit 19120492b9
2 changed files with 10 additions and 2 deletions

View File

@ -156,6 +156,15 @@ impl<Data: Clone + Default> Scope<Data> {
.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)]

View File

@ -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(),