diff --git a/crates/erg_compiler/build_package.rs b/crates/erg_compiler/build_package.rs index 32d292d66..26faac803 100644 --- a/crates/erg_compiler/build_package.rs +++ b/crates/erg_compiler/build_package.rs @@ -824,6 +824,12 @@ impl let deps = self.build_deps_and_module(&path, &mut graph); log!(info "All dependencies have started to analyze"); debug_power_assert!(self.asts.len(), ==, 0); + for path in self.shared.graph.ancestors(&path) { + debug_assert!( + self.shared.promises.is_registered(&path), + "{path} is not registered" + ); + } self.finalize(); match self.main_builder.build_from_ast(ast, mode) { Ok(artifact) => Ok(CompleteArtifact::new( @@ -895,6 +901,7 @@ impl self.shared.promises.wait_until_finished(path); } else if let Some(inliner) = self.inlines.get(path).cloned() { self.build_deps_and_module(&inliner, graph); + self.shared.promises.mark_as_joined(path.clone()); } else { unreachable!("{path} is not found in self.inlines and self.asts"); } @@ -998,10 +1005,17 @@ impl } Err(artifact) => { let ctx = builder.pop_context().unwrap(); - py_mod_cache.register(path, raw_ast, artifact.object, ctx, CheckStatus::Failed); + py_mod_cache.register( + path.clone(), + raw_ast, + artifact.object, + ctx, + CheckStatus::Failed, + ); self.shared.warns.extend(artifact.warns); self.shared.errors.extend(artifact.errors); } } + self.shared.promises.mark_as_joined(path); } }