Skip to content

Commit

Permalink
fix: add debug assertions to PackageBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Sep 18, 2024
1 parent ed6ad90 commit 1712c04
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/erg_compiler/build_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
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(
Expand Down Expand Up @@ -895,6 +901,7 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
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");
}
Expand Down Expand Up @@ -998,10 +1005,17 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
}
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);
}
}

0 comments on commit 1712c04

Please sign in to comment.