Skip to content

Commit e0e091f

Browse files
committed
fix
1 parent 55a86ab commit e0e091f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/asm2wasm.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -774,18 +774,22 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
774774
}
775775
}
776776
auto importResult = getModule()->getImport(curr->target)->functionType->result;
777-
if (isConcreteWasmType(curr->type)) {
778-
if (curr->type != importResult) {
779-
assert(importResult == f64); // we generalized because we had to
777+
if (curr->type != importResult) {
778+
if (importResult == f64) {
779+
// we use a JS f64 value which is the most general, and convert to it
780780
switch (curr->type) {
781781
case i32: replaceCurrent(parent->builder.makeUnary(TruncSFloat64ToInt32, curr)); break;
782782
case f32: replaceCurrent(parent->builder.makeUnary(DemoteFloat64, curr)); break;
783-
default: {} // f64, unreachable, etc., are all good
783+
case none: replaceCurrent(parent->builder.makeDrop(curr)); break;
784+
default: WASM_UNREACHABLE();
784785
}
785-
curr->type = importResult;
786+
} else {
787+
assert(curr->type == none);
788+
// we don't want a return value here, but the import does provide one
789+
replaceCurrent(parent->builder.makeDrop(curr));
786790
}
791+
curr->type = importResult;
787792
}
788-
789793
fixParents();
790794
}
791795

0 commit comments

Comments
 (0)