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
2 changes: 1 addition & 1 deletion src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
incIndent();
maybePrintImplicitBlock(curr->body, true);
maybePrintImplicitBlock(curr->body, false);
doIndent(o, indent);
o << "(catch";
incIndent();
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) {
ret->body = parseExpression(*s[i++]);
}
if (!elementStartsWith(*s[i], "catch")) {
throw ParseException("catch clause does not exist");
throw ParseException("catch clause does not exist", s[i]->line, s[i]->col);
}
ret->catchBody = makeCatch(*s[i++]);
ret->finalize(type);
Expand Down
16 changes: 16 additions & 0 deletions test/exception-handling.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
(local.get $0)
)

(func $foo)
(func $bar)

(func $eh_test (local $exn exnref)
(try
(throw $e0 (i32.const 0))
Expand Down Expand Up @@ -36,5 +39,18 @@
(drop (exnref.pop))
)
)

;; Multiple instructions within try and catch bodies
(try
(block
(call $foo)
(call $bar)
)
(catch
(drop (exnref.pop))
(call $foo)
(call $bar)
)
)
)
)
21 changes: 20 additions & 1 deletion test/exception-handling.wast.from-wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
(func $exnref_test (; 0 ;) (type $FUNCSIG$ee) (param $0 exnref) (result exnref)
(local.get $0)
)
(func $eh_test (; 1 ;) (type $FUNCSIG$v)
(func $foo (; 1 ;) (type $FUNCSIG$v)
(nop)
)
(func $bar (; 2 ;) (type $FUNCSIG$v)
(nop)
)
(func $eh_test (; 3 ;) (type $FUNCSIG$v)
(local $exn exnref)
(try
(throw $e0
Expand Down Expand Up @@ -43,5 +49,18 @@
)
)
)
(try
(block $block
(call $foo)
(call $bar)
)
(catch
(drop
(exnref.pop)
)
(call $foo)
(call $bar)
)
)
)
)
8 changes: 7 additions & 1 deletion test/exception-handling.wast.fromBinary
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
(func $exnref_test (; 0 ;) (type $0) (param $0 exnref) (result exnref)
(local.get $0)
)
(func $eh_test (; 1 ;) (type $1)
(func $foo (; 1 ;) (type $1)
(nop)
)
(func $bar (; 2 ;) (type $1)
(nop)
)
(func $eh_test (; 3 ;) (type $1)
(local $0 exnref)
(try
(throw $event$0
Expand Down
6 changes: 6 additions & 0 deletions test/exception-handling.wast.fromBinary.noDebugInfo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
(local.get $0)
)
(func $1 (; 1 ;) (type $1)
(nop)
)
(func $2 (; 2 ;) (type $1)
(nop)
)
(func $3 (; 3 ;) (type $1)
(local $0 exnref)
(try
(throw $event$0
Expand Down
Binary file added test/try-body-multiple-insts.wasm
Binary file not shown.
26 changes: 26 additions & 0 deletions test/try-body-multiple-insts.wasm.fromBinary
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(module
(type $0 (func))
(func $0 (; 0 ;) (type $0)
(nop)
)
(func $1 (; 1 ;) (type $0)
(nop)
)
(func $2 (; 2 ;) (type $0)
(local $0 exnref)
(try
(block
(call $0)
(call $1)
)
(catch
(drop
(exnref.pop)
)
(call $0)
(call $1)
)
)
)
)