diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc index d4d2279820..b58b3da383 100644 --- a/src/wasm/wasm-js.cc +++ b/src/wasm/wasm-js.cc @@ -1920,14 +1920,14 @@ bool IsSuspendingSignature(const i::wasm::FunctionSig* inner_sig, return true; } -// Given {inner_sig}: externref ti* -> to -// {outer_sig} must be: ti* -> externref +// Given {inner_sig}: externref [ti*] -> [to*] +// {outer_sig} must be: [ti*] -> [externref] bool IsPromisingSignature(const i::wasm::FunctionSig* inner_sig, const i::wasm::FunctionSig* outer_sig) { if (inner_sig->parameter_count() != outer_sig->parameter_count() + 1) { return false; } - if (inner_sig->return_count() != 1 || outer_sig->return_count() != 1) { + if (outer_sig->return_count() != 1) { return false; } if (inner_sig->GetParam(0) != i::wasm::kWasmExternRef) return false; diff --git a/test/mjsunit/wasm/stack-switching.js b/test/mjsunit/wasm/stack-switching.js index bc78b3c708..653f191701 100644 --- a/test/mjsunit/wasm/stack-switching.js +++ b/test/mjsunit/wasm/stack-switching.js @@ -19,7 +19,6 @@ function ToPromising(wasm_export) { let sig = WebAssembly.Function.type(wasm_export); assertTrue(sig.parameters.length > 0); assertEquals('externref', sig.parameters[0]); - assertEquals(1, sig.results.length); let wrapper_sig = { parameters: sig.parameters.slice(1), results: ['externref'] @@ -466,3 +465,16 @@ function TestNestedSuspenders(suspend) { print(arguments.callee.name); TestNestedSuspenders(false); })(); + +(function Regress13231() { + print(arguments.callee.name); + // Check that a promising function with no return is allowed. + let builder = new WasmModuleBuilder(); + let sig_v_r = makeSig([kWasmExternRef], []); + builder.addFunction("export", sig_v_r).addBody([]).exportFunc(); + let instance = builder.instantiate(); + let export_wrapper = ToPromising(instance.exports.export); + let export_sig = WebAssembly.Function.type(export_wrapper); + assertEquals([], export_sig.parameters); + assertEquals(['externref'], export_sig.results); +})();