From 82758ae333646597c0846d35871d3ebcfbccb932 Mon Sep 17 00:00:00 2001 From: sofia Date: Wed, 23 Jul 2025 15:22:58 +0300 Subject: [PATCH] Only test for typedefinitions in current module --- reid/src/mir/fmt.rs | 2 +- reid/src/mir/typecheck.rs | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/reid/src/mir/fmt.rs b/reid/src/mir/fmt.rs index e850fb1..9cbba3b 100644 --- a/reid/src/mir/fmt.rs +++ b/reid/src/mir/fmt.rs @@ -32,7 +32,7 @@ impl Display for Context { impl Display for Module { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "Module({}) {{", self.name)?; + writeln!(f, "Module({}) ({}) {{", self.name, self.module_id)?; let mut state = Default::default(); let mut inner_f = PadAdapter::wrap(f, &mut state); diff --git a/reid/src/mir/typecheck.rs b/reid/src/mir/typecheck.rs index 9d8dfc0..70bd348 100644 --- a/reid/src/mir/typecheck.rs +++ b/reid/src/mir/typecheck.rs @@ -774,15 +774,21 @@ impl TypeKind { fn is_known(&self, refs: &TypeRefs, state: &TypecheckPassState) -> Result<(), ErrorKind> { match &self { TypeKind::Array(type_kind, _) => type_kind.as_ref().is_known(refs, state), - TypeKind::CustomType(custom_type_key) => state - .scope - .types - .get(custom_type_key) - .map(|_| ()) - .ok_or(ErrorKind::NoSuchType( - custom_type_key.0.clone(), - state.module_id.unwrap(), - )), + TypeKind::CustomType(custom_type_key) => { + if custom_type_key.1 == state.module_id.unwrap() { + state + .scope + .types + .get(custom_type_key) + .map(|_| ()) + .ok_or(ErrorKind::NoSuchType( + custom_type_key.0.clone(), + state.module_id.unwrap(), + )) + } else { + Ok(()) + } + } TypeKind::Borrow(type_kind, _) => type_kind.is_known(refs, state), TypeKind::UserPtr(type_kind) => type_kind.is_known(refs, state), TypeKind::CodegenPtr(type_kind) => type_kind.is_known(refs, state),