Skip to content

Commit

Permalink
fix(frontend): Avoid panic if dependency cannot be resolved (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 16, 2023
1 parent 00cf462 commit f35b346
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/noirc_frontend/src/hir/resolution/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ fn resolve_external_dep(
let path = &directive.path.segments;
//
// Fetch the root module from the prelude
let crate_name = path.first().unwrap().0.contents.clone();
let crate_name = path.first().unwrap();
let dep_module = current_def_map
.extern_prelude
.get(&crate_name)
.unwrap_or_else(|| panic!("error reporter: could not find crate {crate_name}"));
.get(&crate_name.0.contents)
.ok_or_else(|| PathResolutionError::Unresolved(crate_name.to_owned()))?;

// Create an import directive for the dependency crate
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
Expand Down

0 comments on commit f35b346

Please sign in to comment.