diff --git a/src/parser/contexts.h b/src/parser/contexts.h index a09433f809d..e9eb708ac9c 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1325,7 +1325,10 @@ struct ParseModuleTypesCtx : TypeParserCtx, return in.err(pos, "expected signature type"); } f->type = type.type; - for (Index i = 0; i < type.names.size(); ++i) { + // If we are provided with too many names (more than the function has), we + // will error on that later when we check the signature matches the type. + // For now, avoid asserting in setLocalName. + for (Index i = 0; i < std::min(type.names.size(), f->getNumLocals()); ++i) { if (type.names[i].is()) { f->setLocalName(i, type.names[i]); } diff --git a/test/lit/parse-error-func-param-type.wast b/test/lit/parse-error-func-param-type.wast new file mode 100644 index 00000000000..04068eca859 --- /dev/null +++ b/test/lit/parse-error-func-param-type.wast @@ -0,0 +1,10 @@ +;; This function's type does not match the param we define for it. + +;; RUN: not wasm-opt %s 2>&1 | filecheck %s +;; CHECK: Fatal: 9:10: error: type does not match provided signature + +(module + (type $0 (func)) + + (func $0 (type $0) (param $var$0 i32)) +)