diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 340266fcf76..4ec87135e65 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -261,7 +261,7 @@ struct PrintSExpression : public Visitor { printCallBody(curr); } void visitCallIndirect(CallIndirect *curr) { - printOpening(o, "call_indirect ") << curr->fullType; + printOpening(o, "call_indirect (type ") << curr->fullType << ')'; incIndent(); for (auto operand : curr->operands) { printFullLine(operand); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 59043f3b8ff..6ef05e0c9a2 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1318,7 +1318,9 @@ Expression* SExpressionWasmBuilder::makeCallImport(Element& s) { Expression* SExpressionWasmBuilder::makeCallIndirect(Element& s) { if (!wasm.table.exists) throw ParseException("no table"); auto ret = allocator.alloc(); - IString type = s[1]->str(); + Element& typeElement = *s[1]; + if (typeElement[0]->str() != "type") throw ParseException("expected 'type' in call_indirect", s.line, s.col); + IString type = typeElement[1]->str(); auto* fullType = wasm.getFunctionTypeOrNull(type); if (!fullType) throw ParseException("invalid call_indirect type", s.line, s.col); ret->fullType = fullType->name;