Skip to content

Commit

Permalink
Fix delegate validation to allow any block target
Browse files Browse the repository at this point in the history
The semantics was changed recently to remove the restriction to
only target try blocks or the function body block:

  WebAssembly/exception-handling#176
  • Loading branch information
takikawa committed Oct 27, 2021
1 parent 62d6b2f commit c7ed7c4
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 c7ed7c4

Please sign in to comment.