Skip to content

Commit d8b83aa

Browse files
committed
fix: async lifted exports with direct results
Avoid lifting the raw core return value for async lifted exports without a retptr. The core return is async progress information, while the component result is delivered through task.return. Additionaly params is now using &sig.results which makes AsyncTaskReturn match the actual canonical ABI core signature: [], [i32], [ptr] etc.
1 parent e4406d9 commit d8b83aa

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

crates/core/src/abi.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,10 +1165,11 @@ impl<'a, B: Bindgen> Generator<'a, B> {
11651165
amt: usize::from(func.result.is_some()),
11661166
});
11671167
}
1168-
} else {
1169-
// With no return pointer in use we can simply lift the
1170-
// result(s) of the function from the result of the core
1171-
// wasm function.
1168+
} else if !async_ {
1169+
// With no return pointer in use for a synchronous call, we can simply lift the
1170+
// result(s) of the function from the result of the core wasm function. For async
1171+
// calls, the component result is delivered via `task.return` and core result is
1172+
// async progress.
11721173
if let Some(ty) = &func.result {
11731174
self.lift(ty)
11741175
}
@@ -1178,11 +1179,7 @@ impl<'a, B: Bindgen> Generator<'a, B> {
11781179
if async_ {
11791180
self.emit(&Instruction::AsyncTaskReturn {
11801181
name: &func.name,
1181-
params: if func.result.is_some() {
1182-
&[WasmType::Pointer]
1183-
} else {
1184-
&[]
1185-
},
1182+
params: &sig.results,
11861183
});
11871184
} else {
11881185
self.emit(&Instruction::Return {

0 commit comments

Comments
 (0)