diff --git a/src/parser/context-decls.cpp b/src/parser/context-decls.cpp index a8723618f8f..d2176b0108c 100644 --- a/src/parser/context-decls.cpp +++ b/src/parser/context-decls.cpp @@ -328,12 +328,18 @@ bool ParseDeclsCtx::skipFunctionBody() { if (*kw == "block"sv || *kw == "loop"sv || *kw == "if"sv || *kw == "try"sv || *kw == "try_table"sv) { in.takeID(); - (void)typeuse(*this); + auto pos = in.getPos(); + if (typeuse(*this).getErr()) { + in.setPos(pos); + } continue; } if (*kw == "call_indirect"sv || *kw == "return_call_indirect"sv) { (void)maybeTableidx(*this); - (void)typeuse(*this, false); + auto pos = in.getPos(); + if (typeuse(*this, false).getErr()) { + in.setPos(pos); + } continue; } continue; diff --git a/test/lit/parse-bad-typeuse.wast b/test/lit/parse-bad-typeuse.wast new file mode 100644 index 00000000000..cea7ee7aa78 --- /dev/null +++ b/test/lit/parse-bad-typeuse.wast @@ -0,0 +1,5 @@ +;; RUN: not wasm-opt %s 2>&1 | filecheck %s + +;; CHECK: Fatal: {{.*}}:5:27: error: expected type index or identifier + +(module (func (block (type $))))