Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): Avoid panic if dependency cannot be resolved #1719

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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