Skip to content

Commit

Permalink
improve errors
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Jan 18, 2024
1 parent e269ef9 commit 68423e9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions crates/concrete_codegen_mlir/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn compile_program(
let module_info = ast_helper
.modules
.get(&module.name.name)
.expect("module not found");
.unwrap_or_else(|| panic!("module info not found for {}", module.name.name));
compile_module(session, ctx, mlir_module, &ast_helper, module_info, module)?;
}
Ok(())
Expand Down Expand Up @@ -185,7 +185,12 @@ fn compile_module(
for import in &module.imports {
let target_module = ast_helper
.get_module_from_import(&import.module)
.expect("failed to find import");
.unwrap_or_else(|| {
panic!(
"failed to find import {:?} in module {}",
import, module.name.name
)
});

for symbol in &import.symbols {
imports.insert(symbol.name.clone(), target_module);
Expand All @@ -211,10 +216,12 @@ fn compile_module(
ModuleDefItem::Struct(_) => todo!(),
ModuleDefItem::Type(_) => todo!(),
ModuleDefItem::Module(info) => {
let module_info = module_info
.modules
.get(&info.name.name)
.expect("submodule not found");
let module_info = module_info.modules.get(&info.name.name).unwrap_or_else(|| {
panic!(
"submodule {} not found while compiling module {}",
info.name.name, module.name.name
)
});
compile_module(session, context, mlir_module, ast_helper, module_info, info)?;
}
}
Expand Down

0 comments on commit 68423e9

Please sign in to comment.