Skip to content

Commit 012cd90

Browse files
fix: embedding splicer error handling
This commit fixes a regression in function generation when error handling is involved. The buggy code over-eagerly checks whether there is an error type type present on a result, when there may legitimately not be (e.g. `result<t>` in WIT). The fix is to check *only* for whether the types are returned as a pair (indicating a `result`) at all.
1 parent 21b657c commit 012cd90

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

crates/spidermonkey-embedding-splicer/src/bindgen.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,15 +859,13 @@ impl JsBindgen<'_> {
859859
}
860860
}
861861

862-
let err = if get_result_types(self.resolve, func.result)
863-
.is_some_and(|(_, err_ty)| err_ty.is_some())
864-
{
862+
let err = if get_result_types(self.resolve, func.result).is_some() {
865863
match abi {
866864
AbiVariant::GuestExport => ErrHandling::ThrowResultErr,
867865
AbiVariant::GuestImport => ErrHandling::ResultCatchHandler,
868-
AbiVariant::GuestImportAsync => todo!(),
869-
AbiVariant::GuestExportAsync => todo!(),
870-
AbiVariant::GuestExportAsyncStackful => todo!(),
866+
AbiVariant::GuestImportAsync
867+
| AbiVariant::GuestExportAsync
868+
| AbiVariant::GuestExportAsyncStackful => todo!(),
871869
}
872870
} else {
873871
ErrHandling::None

test/cases/http-server/source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
export const incomingHandler = {
1010
handle(incomingRequest, responseOutparam) {
1111
const outgoingResponse = new OutgoingResponse(new Fields());
12-
let outgoingBody = outgoingResponse.body().val;
12+
let outgoingBody = outgoingResponse.body();
1313
{
14-
let outputStream = outgoingBody.write().val;
14+
let outputStream = outgoingBody.write();
1515
outputStream.blockingWriteAndFlush(
1616
new Uint8Array(new TextEncoder().encode('Hello world!')),
1717
);

0 commit comments

Comments
 (0)