Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 21, 2024
1 parent 139827f commit 6e03426
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
12 changes: 8 additions & 4 deletions crates/js-component-bindgen/src/esm_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ impl EsmBindgen {
}
iface = match iface.get_mut(&path[i]).unwrap() {
ImportBinding::Interface(iface) => iface,
ImportBinding::Local(_) => panic!(
"Imported interface {} cannot be both a function and an interface",
&path[0..i].join(".")
),
ImportBinding::Local(local) => {
panic!(
"Internal bindgen error: Import '{}' cannot be both an interface '{}' and a function '{}'",
&path[0..i + 1].join("."),
&path[i + 1..].join("."),
&local[0],
);
}
};
}
if let Some(ref mut existing) = iface.get_mut(&path[path.len() - 1]) {
Expand Down
17 changes: 11 additions & 6 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,19 +1407,24 @@ impl<'a> Instantiator<'a, '_> {
wit_parser::TypeOwner::Interface(iface) => {
match &self.resolve.interfaces[iface].name {
Some(name) => (WorldKey::Interface(iface), Some(name.as_str())),
None => (
self.resolve.worlds[self.world]
None => {
let key = self.resolve.worlds[self.world]
.imports
.iter()
.find(|&(_, item)| match item {
WorldItem::Interface { id, .. } => *id == iface,
_ => false,
})
.unwrap()
.0
.clone(),
None,
),
.0;
(
key.clone(),
match key {
WorldKey::Name(ref name) => Some(name.as_str()),
WorldKey::Interface(_) => None,
},
)
}
}
}
wit_parser::TypeOwner::None => unimplemented!(),
Expand Down

0 comments on commit 6e03426

Please sign in to comment.