Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions crates/wit-component/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,29 @@ impl ExportMap {
bail!("cannot componentize module that exports multiple memories")
}

// Every async-with-callback-lifted export must have a callback.
for (name, export) in &self.names {
match export {
Export::WorldFunc(_, _, AbiVariant::GuestExportAsync) => {
if !matches!(
self.names.get(&format!("[callback]{name}")),
Some(Export::WorldFuncCallback(_))
) {
bail!("missing callback for `{name}`");
}
}
Export::InterfaceFunc(_, _, _, AbiVariant::GuestExportAsync) => {
if !matches!(
self.names.get(&format!("[callback]{name}")),
Some(Export::InterfaceFuncCallback(_, _))
) {
bail!("missing callback for `{name}`");
}
}
_ => {}
}
}

// All of `exports` must be exported and found within this module.
for export in exports {
let require_interface_func = |interface: InterfaceId, name: &str| -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
failed to decode world from module: module was not valid: missing callback for `[async-lift]foo`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(module
(func (export "[async-lift]foo") (param i32 i32) (result i32) unreachable)
(func (export "[async-lift]foo:foo/bar#foo") (param i32 i32) (result i32) unreachable)
(memory (export "memory") 1)
(func (export "cabi_realloc") (param i32 i32 i32 i32) (result i32) unreachable)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package foo:foo;

interface bar {
foo: func(s: string) -> string;
}

world module {
export bar;
export foo: func(s: string) -> string;
}
Loading