Skip to content

Commit

Permalink
Fix parser error on block params (#6932)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlively authored Sep 11, 2024
1 parent 0901ba7 commit 0cbe03a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions test/lit/parse-bad-block-params.wast
Original file line number Diff line number Diff line change
@@ -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)
)
)
)

0 comments on commit 0cbe03a

Please sign in to comment.