Skip to content

Commit f35b346

Browse files
authored
fix(frontend): Avoid panic if dependency cannot be resolved (#1719)
1 parent 00cf462 commit f35b346

File tree

1 file changed

+3
-3
lines changed
  • crates/noirc_frontend/src/hir/resolution

1 file changed

+3
-3
lines changed

crates/noirc_frontend/src/hir/resolution/import.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ fn resolve_external_dep(
192192
let path = &directive.path.segments;
193193
//
194194
// Fetch the root module from the prelude
195-
let crate_name = path.first().unwrap().0.contents.clone();
195+
let crate_name = path.first().unwrap();
196196
let dep_module = current_def_map
197197
.extern_prelude
198-
.get(&crate_name)
199-
.unwrap_or_else(|| panic!("error reporter: could not find crate {crate_name}"));
198+
.get(&crate_name.0.contents)
199+
.ok_or_else(|| PathResolutionError::Unresolved(crate_name.to_owned()))?;
200200

201201
// Create an import directive for the dependency crate
202202
let path_without_crate_name = &path[1..]; // XXX: This will panic if the path is of the form `use dep::std` Ideal algorithm will not distinguish between crate and module

0 commit comments

Comments
 (0)