Fix module scopes being linked

This commit is contained in:
Sofia 2025-07-15 20:09:33 +03:00
parent 6788ef1690
commit 1acaa29a12
3 changed files with 13 additions and 8 deletions

View File

@ -103,13 +103,18 @@ pub fn compile_module(
} }
pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> { pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> {
#[cfg(debug_assertions)]
dbg!(&context);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
println!("{}", &context); println!("{}", &context);
let state = context.pass(&mut LinkerPass); let state = context.pass(&mut LinkerPass);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
println!("{:?}\n{}", &context, &context); println!("{}", &context);
#[cfg(debug_assertions)]
dbg!(&state);
if !state.errors.is_empty() { if !state.errors.is_empty() {
return Err(ReidError::LinkerErrors(state.errors)); return Err(ReidError::LinkerErrors(state.errors));
@ -119,10 +124,10 @@ pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> {
let state = context.pass(&mut TypeInference { refs: &refs }); let state = context.pass(&mut TypeInference { refs: &refs });
#[cfg(debug_assertions)]
dbg!(&state, &refs);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
println!("{}", &context); println!("{}", &context);
#[cfg(debug_assertions)]
dbg!(&state, &refs);
if !state.errors.is_empty() { if !state.errors.is_empty() {
return Err(ReidError::TypeInferenceErrors(state.errors)); return Err(ReidError::TypeInferenceErrors(state.errors));
@ -130,10 +135,10 @@ pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> {
let state = context.pass(&mut TypeCheck { refs: &refs }); let state = context.pass(&mut TypeCheck { refs: &refs });
#[cfg(debug_assertions)]
dbg!(&state);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
println!("{}", &context); println!("{}", &context);
#[cfg(debug_assertions)]
dbg!(&state);
if !state.errors.is_empty() { if !state.errors.is_empty() {
return Err(ReidError::TypeCheckErrors(state.errors)); return Err(ReidError::TypeCheckErrors(state.errors));

View File

@ -61,8 +61,8 @@ impl Display for FunctionDefinitionKind {
write!(f, "{}", block)?; write!(f, "{}", block)?;
Ok(()) Ok(())
} }
Self::Extern(true) => write!(f, "<Classical Extern>"), Self::Extern(true) => write!(f, "<Imported Extern>"),
Self::Extern(false) => write!(f, "<Imported Extern>"), Self::Extern(false) => write!(f, "<Linked Extern>"),
} }
} }
} }

View File

@ -210,7 +210,7 @@ impl Context {
let mut scope = Scope::default(); let mut scope = Scope::default();
pass.context(self, PassState::from(&mut state, &mut scope)); pass.context(self, PassState::from(&mut state, &mut scope));
for module in &mut self.modules { for module in &mut self.modules {
module.pass(pass, &mut state, &mut scope); module.pass(pass, &mut state, &mut scope.inner());
} }
state state
} }