Skip to content

Commit

Permalink
Fix delegate validation to allow any block target (#1748)
Browse files Browse the repository at this point in the history
This PR makes wabt's validation behavior for `try-delegate` match the spec and spec interpreter. The spec now allows the delegate to target any block, rather than just `try` blocks and the function body block.

The semantics was changed a bit ago as discussed in WebAssembly/exception-handling#176
  • Loading branch information
takikawa committed Oct 29, 2021
1 parent 3bb4f48 commit 7659bfb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
4 changes: 0 additions & 4 deletions src/type-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,6 @@ Result TypeChecker::OnDelegate(Index depth) {
// Delegate starts counting after the current try, as the delegate
// instruction is not actually in the try block.
CHECK_RESULT(GetLabel(depth + 1, &label));
if (Failed(Check2LabelTypes(label, LabelType::Try, LabelType::Func))) {
PrintError("try-delegate must target a try block or function label");
result = Result::Error;
}

Label* try_label;
CHECK_RESULT(TopLabel(&try_label));
Expand Down
36 changes: 0 additions & 36 deletions test/typecheck/bad-delegate-target.txt

This file was deleted.

38 changes: 38 additions & 0 deletions test/typecheck/try-delegate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;;; TOOL: wat2wasm
;;; ARGS: --enable-exceptions
(module
(tag $e)
(func
try $l
try
delegate $l
catch $e
end)

(func
try $l
try
try
delegate $l
catch $e
end
catch $e
end)

(func
block $l
try
delegate $l
end)

(func
try $l
catch_all
try
delegate $l
end)

(func
try
delegate 0)
)

0 comments on commit 7659bfb

Please sign in to comment.