diff options
author | Thomas Lively <tlively@google.com> | 2024-09-11 15:59:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 22:59:55 +0000 |
commit | 0cbe03a13abd4a59dafce5042ac979adf151a702 (patch) | |
tree | 610b72abdf11ceaeacf1b002d0dd1531caf9144e | |
parent | 0901ba7fff0bac1def4d457b15e4771368abf00d (diff) | |
download | binaryen-0cbe03a13abd4a59dafce5042ac979adf151a702.tar.gz binaryen-0cbe03a13abd4a59dafce5042ac979adf151a702.tar.bz2 binaryen-0cbe03a13abd4a59dafce5042ac979adf151a702.zip |
Fix parser error on block params (#6932)
The error checking we had to report an error when the input contains
block parameters was in a code path that is no longer executed under
normal circumstances. Specifically, it was part of the
`ParseModuleTypesCtx` phase of parsing, which no longer parses function
bodies. Move the error checking to the `ParseDefsCtx` phase, which does
parse function bodies.
Fixes #6929.
-rw-r--r-- | src/parser/contexts.h | 12 | ||||
-rw-r--r-- | test/lit/parse-bad-block-params.wast | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 7e70b6776..387cb146e 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1259,12 +1259,6 @@ struct ParseModuleTypesCtx : TypeParserCtx<ParseModuleTypesCtx>, } Result<HeapType> getBlockTypeFromTypeUse(Index pos, TypeUse use) { - assert(use.type.isSignature()); - if (use.type.getSignature().params != Type::none) { - return in.err(pos, "block parameters not yet supported"); - } - // TODO: Once we support block parameters, return an error here if any of - // them are named. return use.type; } @@ -1451,6 +1445,12 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { } Result<HeapType> getBlockTypeFromTypeUse(Index pos, HeapType type) { + assert(type.isSignature()); + if (type.getSignature().params != Type::none) { + return in.err(pos, "block parameters not yet supported"); + } + // TODO: Once we support block parameters, return an error here if any of + // them are named. return type; } diff --git a/test/lit/parse-bad-block-params.wast b/test/lit/parse-bad-block-params.wast new file mode 100644 index 000000000..67e05989c --- /dev/null +++ b/test/lit/parse-bad-block-params.wast @@ -0,0 +1,12 @@ +;; RUN: not wasm-opt %s -S -o - 2>&1 | filecheck %s + +;; CHECK: 8:11: error: block parameters not yet supported + +(module + (func + (i32.const 0) + (block (param i32) + (drop) + ) + ) +) |