From b4cd0b75a21226134aefba6728ae63ecf14d1da9 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 28 Jan 2025 16:50:52 -0800 Subject: [PATCH 1/3] fix --- src/parser/contexts.h | 5 ++++- test/lit/parse-error-func-param-type.wast | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/lit/parse-error-func-param-type.wast 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..9446c023e2e --- /dev/null +++ b/test/lit/parse-error-func-param-type.wast @@ -0,0 +1,11 @@ +;; This function's type does not match the param we define for it. + +;; RUN: not wasm-opt %s 2>&1 | filecheck %s +;; CHECK: Fatal: 5:10: error: type does not match provided signature + +(module + (type $0 (func)) + + (func $0 (type $0) (param $var$0 i32) + ) +) From 53e03a0135aebe02dbb6efc8fb5657904007bc34 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 29 Jan 2025 11:30:36 -0800 Subject: [PATCH 2/3] Update test/lit/parse-error-func-param-type.wast Co-authored-by: Thomas Lively --- test/lit/parse-error-func-param-type.wast | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/lit/parse-error-func-param-type.wast b/test/lit/parse-error-func-param-type.wast index 9446c023e2e..6b3c20070a5 100644 --- a/test/lit/parse-error-func-param-type.wast +++ b/test/lit/parse-error-func-param-type.wast @@ -6,6 +6,5 @@ (module (type $0 (func)) - (func $0 (type $0) (param $var$0 i32) - ) + (func $0 (type $0) (param $var$0 i32)) ) From 65fd56a92f5e706e3226d7511a6a42e3aaa43608 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 29 Jan 2025 12:59:56 -0800 Subject: [PATCH 3/3] fix --- test/lit/parse-error-func-param-type.wast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lit/parse-error-func-param-type.wast b/test/lit/parse-error-func-param-type.wast index 9446c023e2e..d139da7bf58 100644 --- a/test/lit/parse-error-func-param-type.wast +++ b/test/lit/parse-error-func-param-type.wast @@ -1,7 +1,7 @@ ;; This function's type does not match the param we define for it. ;; RUN: not wasm-opt %s 2>&1 | filecheck %s -;; CHECK: Fatal: 5:10: error: type does not match provided signature +;; CHECK: Fatal: 9:10: error: type does not match provided signature (module (type $0 (func))