@@ -115,8 +115,7 @@ A try-catch block contains zero or more `catch` blocks and zero or one
115
115
` catch_all ` block. All ` catch ` blocks must precede the ` catch_all ` block, if
116
116
any. The ` catch ` /` catch_all ` instructions (within the try construct) are called
117
117
the _ catching_ instructions. There may not be any ` catch ` or ` catch_all ` blocks
118
- after a ` try ` , in which case the whole ` try ` block is effectively a regular
119
- block.
118
+ after a ` try ` , in which case the ` try ` block does not catch any exceptions.
120
119
121
120
The _ body_ of the try block is the list of instructions before the first
122
121
catching instruction. The _ body_ of each catch block is the sequence of
@@ -241,9 +240,9 @@ caught by `catch 1`. In wat format, the argument for the `rethrow` instructions
241
240
can also be written as a label, like branches. So ` rethrow 0 ` in the example
242
241
above can also be written as ` rethrow $l3 ` .
243
242
244
- Note that ` rethrow 2 ` is not allowed because it does not reference a catch
245
- block. Rather, it references a ` block ` instruction, so it will result in a
246
- validation failure.
243
+ Note that ` rethrow 2 ` is not allowed because it does not refer to a ` try ` label
244
+ from within its catch block. Rather, it references a ` block ` instruction, so it
245
+ will result in a validation failure.
247
246
248
247
Note that the example below is a validation failure:
249
248
```
@@ -271,9 +270,8 @@ delegate label
271
270
272
271
The ` delegate ` clause does not have an associated body, so try-delegate blocks
273
272
don't have an ` end ` instruction at the end. The ` delegate ` instruction takes a
274
- label defined by a construct in which they are enclosed, and delegates exception
275
- handling to a catch block specified by the label. For example, consider this
276
- code:
273
+ try label and delegates exception handling to a ` catch ` /` catch_all ` /` delegate `
274
+ specified by the ` try ` label. For example, consider this code:
277
275
278
276
```
279
277
try $l1
@@ -296,17 +294,22 @@ correspond to a `try` instruction, it is a validation failure.
296
294
Note that the example below is a validation failure:
297
295
```
298
296
try $l1
299
- catch 1
297
+ catch
300
298
try
301
299
call $foo
302
300
delegate $l1 ;; (= delegate 0)
303
301
catch_all
304
302
...
305
303
end
306
304
```
307
- Here ` delegate ` is trying to delegate to ` catch 1 ` , which exists before the
308
- ` delegate ` . The ` delegate ` instruction can only delegate to ` catch ` /` catch_all `
309
- blocks in a ` try ` or to another ` delegate ` below the ` delegate ` itself.
305
+ Here ` delegate ` is trying to delegate to ` catch ` , which exists before the
306
+ ` delegate ` . The ` delegate ` instruction can only target ` try ` label whose
307
+ catching instructions (` catch ` /` catch_all ` /` delegate ` ) come after the
308
+ ` delegate ` instruction.
309
+
310
+ ` delegate ` can also target ` catch ` -less ` try ` , in which case the effect is the
311
+ same as if the ` try ` has catches but none of the catches are able to handle the
312
+ exception.
310
313
311
314
### JS API
312
315
0 commit comments