diff options
-rw-r--r-- | src/wasm/wasm-binary.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 57a2bc95c..95658cbe7 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2057,7 +2057,13 @@ void WasmBinaryBuilder::readImports() { Name name(std::string("fimport$") + std::to_string(functionCounter++)); auto index = getU32LEB(); functionTypes.push_back(getTypeByIndex(index)); - auto curr = builder.makeFunction(name, getTypeByIndex(index), {}); + auto type = getTypeByIndex(index); + if (!type.isSignature()) { + throwError(std::string("Imported function ") + module.str + '.' + + base.str + + "'s type must be a signature. Given: " + type.toString()); + } + auto curr = builder.makeFunction(name, type, {}); curr->module = module; curr->base = base; functionImports.push_back(curr.get()); |