diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 12 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 3 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 3 |
3 files changed, 7 insertions, 11 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 84834352b..db253fa6e 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -6080,10 +6080,12 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { // blocks instead. curr->type = getType(); curr->body = getBlockOrSingleton(curr->type); - if (lastSeparator != BinaryConsts::Catch && - lastSeparator != BinaryConsts::CatchAll && - lastSeparator != BinaryConsts::Delegate) { - throwError("No catch instruction within a try scope"); + + // try without catch or delegate + if (lastSeparator == BinaryConsts::End) { + curr->finalize(); + out = curr; + return; } Builder builder(wasm); @@ -6200,7 +6202,7 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { // (catch $e // (block ;; Now this can be deleted when writing binary // ... - // (br $label0) + // (br $label) // ) // ) // ) diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 9c2d028a4..8c0fb9b2d 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2470,9 +2470,6 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) { throw ParseException( "there should be at most one catch_all block at the end", s.line, s.col); } - if (ret->catchBodies.empty() && !ret->isDelegate()) { - throw ParseException("no catch bodies or delegate", s.line, s.col); - } ret->finalize(type); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 6035a38a9..15b17bf26 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2078,9 +2078,6 @@ void FunctionValidator::visitTry(Try* curr) { shouldBeFalse(curr->isCatch() && curr->isDelegate(), curr, "try cannot have both catch and delegate at the same time"); - shouldBeTrue(curr->isCatch() || curr->isDelegate(), - curr, - "try should have either catches or a delegate"); if (curr->isDelegate()) { noteDelegate(curr->delegateTarget, curr); |