diff --git a/parser/src/sema/import_resolver.rs b/parser/src/sema/import_resolver.rs index 70ed93c43..54ce0ff12 100644 --- a/parser/src/sema/import_resolver.rs +++ b/parser/src/sema/import_resolver.rs @@ -70,14 +70,16 @@ impl VisitMut for ImportResolver<'_> { Ok(value) => value, Err(err) => return ControlFlow::Break(err), }; - for export in imported_from.exports() { - let name = export.name(); - // We fetch the item from the set, rather than simply - // check for containment, because we want the span associated - // with the item in the set, not the span associated with the - // export. - if let Some(item) = items.get(&name) { - self.import(module, *from, *item, export)?; + for item in items.iter() { + match imported_from.get(item) { + Some(export) => { + self.import(module, *from, *item, export)?; + }, + None => { + return ControlFlow::Break(SemanticAnalysisError::ImportUndefined( + *from, + )); + }, } } },