Skip to content

Commit 7659bfb

Browse files
authored
Fix delegate validation to allow any block target (#1748)
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
1 parent 3bb4f48 commit 7659bfb

File tree

3 files changed

+38
-40
lines changed

3 files changed

+38
-40
lines changed

src/type-checker.cc

-4
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,6 @@ Result TypeChecker::OnDelegate(Index depth) {
569569
// Delegate starts counting after the current try, as the delegate
570570
// instruction is not actually in the try block.
571571
CHECK_RESULT(GetLabel(depth + 1, &label));
572-
if (Failed(Check2LabelTypes(label, LabelType::Try, LabelType::Func))) {
573-
PrintError("try-delegate must target a try block or function label");
574-
result = Result::Error;
575-
}
576572

577573
Label* try_label;
578574
CHECK_RESULT(TopLabel(&try_label));

test/typecheck/bad-delegate-target.txt

-36
This file was deleted.

test/typecheck/try-delegate.txt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;;; TOOL: wat2wasm
2+
;;; ARGS: --enable-exceptions
3+
(module
4+
(tag $e)
5+
(func
6+
try $l
7+
try
8+
delegate $l
9+
catch $e
10+
end)
11+
12+
(func
13+
try $l
14+
try
15+
try
16+
delegate $l
17+
catch $e
18+
end
19+
catch $e
20+
end)
21+
22+
(func
23+
block $l
24+
try
25+
delegate $l
26+
end)
27+
28+
(func
29+
try $l
30+
catch_all
31+
try
32+
delegate $l
33+
end)
34+
35+
(func
36+
try
37+
delegate 0)
38+
)

0 commit comments

Comments
 (0)