Skip to content

Commit d1aaca2

Browse files
fix(core): async import emission
This commit fixes async import emissions in the case of lowered args and lifted resutls. There were a few bugs to fix: - AsyncTaskReturn was not being emitted - Implementation for async imports was not present
1 parent 799fdb6 commit d1aaca2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

crates/core/src/abi.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,21 @@ impl<'a, B: Bindgen> Generator<'a, B> {
10931093
}
10941094

10951095
// Emit the function return
1096-
self.emit(&Instruction::Return {
1097-
func,
1098-
amt: usize::from(func.result.is_some()),
1099-
});
1096+
if async_ {
1097+
self.emit(&Instruction::AsyncTaskReturn {
1098+
name: &func.name,
1099+
params: if func.result.is_some() {
1100+
&[WasmType::Pointer]
1101+
} else {
1102+
&[]
1103+
},
1104+
});
1105+
} else {
1106+
self.emit(&Instruction::Return {
1107+
func,
1108+
amt: usize::from(func.result.is_some()),
1109+
});
1110+
}
11001111
}
11011112

11021113
LiftLower::LiftArgsLowerResults => {
@@ -1134,7 +1145,10 @@ impl<'a, B: Bindgen> Generator<'a, B> {
11341145
for (param_name, ty) in func.params.iter() {
11351146
let Some(types) = flat_types(self.resolve, ty, Some(max_flat_params))
11361147
else {
1137-
panic!("failed to flatten types during direct parameter lifting ('{param_name}' in func '{}')", func.name);
1148+
panic!(
1149+
"failed to flatten types during direct parameter lifting ('{param_name}' in func '{}')",
1150+
func.name
1151+
);
11381152
};
11391153
for _ in 0..types.len() {
11401154
self.emit(&Instruction::GetArg { nth: offset });

0 commit comments

Comments
 (0)