Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/parser/wast-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Result<Literals> consts(Lexer& in) {
return lits;
}

MaybeResult<Action> action(Lexer& in) {
MaybeResult<Action> maybeAction(Lexer& in) {
if (in.takeSExprStart("invoke"sv)) {
auto id = in.takeID();
auto name = in.takeName();
Expand Down Expand Up @@ -79,6 +79,14 @@ MaybeResult<Action> action(Lexer& in) {
return {};
}

Result<Action> action(Lexer& in) {
if (auto a = maybeAction(in)) {
CHECK_ERR(a);
return *a;
}
return in.err("expected action");
}

// (module id? binary string*)
// (module id? quote string*)
// (module ...)
Expand Down Expand Up @@ -348,7 +356,7 @@ MaybeResult<Assertion> assertTrap(Lexer& in) {
return {};
}
auto pos = in.getPos();
if (auto a = action(in)) {
if (auto a = maybeAction(in)) {
CHECK_ERR(a);
auto msg = in.takeString();
if (!msg) {
Expand Down Expand Up @@ -423,7 +431,7 @@ Result<WASTCommand> command(Lexer& in) {
CHECK_ERR(cmd);
return *cmd;
}
if (auto cmd = action(in)) {
if (auto cmd = maybeAction(in)) {
CHECK_ERR(cmd);
return *cmd;
}
Expand Down
8 changes: 8 additions & 0 deletions test/lit/parse-bad-assertion.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; Check that we properly error when an action is missing from an assertion that
;; requires one. Regression test for #6872.

;; RUN: not wasm-shell %s 2>&1 | filecheck %s

(assert_exhaustion "wrong, lol")

;; CHECK: 6:19: error: expected action