Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 4d6c635

Browse files
committed
Cannot rethrow exceptions caught by unwind blocks
1 parent 275c449 commit 4d6c635

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

proposals/exception-handling/Exceptions.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ Note that a caught exception can be rethrown using the `rethrow` instruction.
238238

239239
### Rethrowing an exception
240240

241-
The `rethrow` instruction can only appear in the body of a catch/catch_all block
242-
but not within the body of an unwind block. It always re-throws the exception
243-
caught by an enclosing catch block.
241+
The `rethrow` instruction can only appear in the body of a
242+
catch/catch_all/unwind block. It always re-throws the exception caught by an
243+
enclosing catch block.
244244

245245
Associated with the `rethrow` instruction is a _label_. The label is used to
246246
disambiguate which exception is to be rethrown, when inside nested catch blocks.
@@ -297,6 +297,21 @@ end
297297
The `rethrow` here references `try $l2`, but the `rethrow` is not within its
298298
`catch` block.
299299

300+
Also, the `rethrow` instruction cannot rethrow an exception caught
301+
by an unwind block. For example:
302+
```
303+
try $l1
304+
unwind
305+
try $l2
306+
catch
307+
try $l3
308+
unwind
309+
rethrow label ;; only $l2 is valid
310+
end
311+
end
312+
end
313+
```
314+
300315
### Try-delegate blocks
301316

302317
Try blocks can also be used with the `delegate` instruction. A try-delegate

0 commit comments

Comments
 (0)