diff --git a/crates/wit-component/src/encoding.rs b/crates/wit-component/src/encoding.rs index f0992100fd..5e5fa09953 100644 --- a/crates/wit-component/src/encoding.rs +++ b/crates/wit-component/src/encoding.rs @@ -515,7 +515,11 @@ impl<'a> EncodingState<'a> { .exported_instances .get(&interface) .copied() - .unwrap_or_else(|| self.imported_instances[&interface]); + .unwrap_or_else(|| { + *self.imported_instances.get(&interface).unwrap_or_else(|| { + panic!("interface with index {} of type with index {} missing from imported instances", interface.index(), id.index()) + }) + }); self.component.alias_type_export(instance, name) } diff --git a/crates/wit-component/src/metadata.rs b/crates/wit-component/src/metadata.rs index 005e518f34..ad58e477a7 100644 --- a/crates/wit-component/src/metadata.rs +++ b/crates/wit-component/src/metadata.rs @@ -163,7 +163,14 @@ pub fn encode( .iter() .filter(|(_, p)| p.name == pkg.name) .count() - == 1 + == 1, + "expected exactly one package with name {}, got names: {:?}", + pkg.name, + resolve + .packages + .iter() + .map(|(_x, p)| p.name.clone()) + .collect::>() ); let mut ret = Vec::new();