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

Commit a30dd5c

Browse files
committed
Small fixes on formal spec overview/examples
- Removes a link next to `[1]`. The link is also in the footnote so it's not strictly necessary, and adding a link right next to `[1]` makes `[]` disappear, so it appears as just `1`, which isn't probably what the author intended. - Both of `throw/catch x` and `throw/catch $x` are being used. Unified them into `throw/catch $x`. - Fixed a location of `$label2` in a test.
1 parent 3dc715a commit a30dd5c

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

proposals/exception-handling/Exceptions-formal-examples.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that the block contexts and throw contexts given for the reductions are the
2020

2121
The only example with an almost full reduction trace, and all new instructions. Such explicit reduction steps are only shown in Example 4 and Example 5, to highlight the reduction step of the administrative `delegate`.
2222

23-
In the following reduction, we don't show the first 4 steps, which just reduce the several `try`s and the `throw x` to their respective administrative instructions. The type of the tag `$x` here is `[]→[]`.
23+
In the following reduction, we don't show the first 4 steps, which just reduce the several `try`s and the `throw $x` to their respective administrative instructions. The type of the tag `$x` here is `[]→[]`.
2424

2525
```
2626
(tag $x)
@@ -153,11 +153,11 @@ Use the trivial throw context `T` again, this time to match the throw to the `ca
153153
Location of a rethrown exception. Let `x, y, z` be tag indices of tags with type `[t_x]→[]`, `[t_y]→[]`, and `[t_z]→[]` respectively. Let `val_p : t_p` for every `p` among `x, y, z`.
154154

155155
```
156-
try
156+
try $label2
157157
val_x
158-
throw x
159-
catch x
160-
try $label2
158+
throw $x
159+
catch $x
160+
try
161161
val_y
162162
throw y
163163
catch_all
@@ -177,8 +177,8 @@ Folded it looks as follows.
177177
(try
178178
(do
179179
val_x
180-
(throw x))
181-
(catch x ;; <--- (rethrow 2) targets this catch.
180+
(throw $x))
181+
(catch $x ;; <--- (rethrow 2) targets this catch.
182182
(try
183183
(do
184184
val_y
@@ -222,7 +222,7 @@ This reduces to `val_x (throw a_x)`, throwing to the caller.
222222
(func
223223
try $label0
224224
rethrow $label0 ;; cannot be done, because it's not within catch below
225-
catch x
225+
catch $x
226226
end)
227227
```
228228

@@ -237,7 +237,7 @@ This is a validation error (no catch block at given rethrow depth).
237237
```
238238
(try $l
239239
(do
240-
(throw x))
240+
(throw $x))
241241
(delegate $l))
242242
```
243243

@@ -252,17 +252,17 @@ try $label1
252252
try
253253
try $label0
254254
try
255-
throw x
255+
throw $x
256256
delegate $label0 ;; delegate 0
257257
delegate $label1 ;; delegate 1
258258
catch_all
259259
end
260-
catch x
260+
catch $x
261261
instr*
262262
end
263263
```
264264

265-
In folded form and reduced to the point `throw x` is called, this is:
265+
In folded form and reduced to the point `throw $x` is called, this is:
266266

267267
```
268268
(label_0{}
@@ -295,7 +295,7 @@ The `delegate{ 1 }` reduces using the trivial throw context and the block contex
295295
(catch_0{ a_x instr* }
296296
(throw a_x) end) end)
297297
```
298-
The thrown exception is (eventually) caught by the outer try's `catch x`, so the above reduces to the following.
298+
The thrown exception is (eventually) caught by the outer try's `catch $x`, so the above reduces to the following.
299299

300300
```
301301
(label_0 {}
@@ -310,7 +310,7 @@ The thrown exception is (eventually) caught by the outer try's `catch x`, so the
310310
```
311311
try (result i32)
312312
try $label0
313-
throw x
313+
throw $x
314314
catch_all
315315
try
316316
throw y
@@ -328,7 +328,7 @@ In folded form this is:
328328
(do
329329
(try
330330
(do
331-
(throw x))
331+
(throw $x))
332332
(catch_all
333333
(try
334334
(do

proposals/exception-handling/Exceptions-formal-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ label_m{} B^l[ delegate{l} T[val^n (throw a)] end ] end
185185
↪ val^n (throw a)
186186
```
187187

188-
Note that the last reduction step above is similar to the reduction of `br l` [1](https://webassembly.github.io/spec/core/exec/instructions.html#xref-syntax-instructions-syntax-instr-control-mathsf-br-l), if we look at the entire `delegate{l}...end` as the `br l`, but also doing a throw after it breaks.
188+
Note that the last reduction step above is similar to the reduction of `br l` [1], if we look at the entire `delegate{l}...end` as the `br l`, but also doing a throw after it breaks.
189189

190190
There is a subtle difference though. The instruction `br l` searches for the `l+1`th surrounding block and breaks out after that block. Because `delegate{l}` is always wrapped in its own `label_n{} ... end` [2], with the same lookup as for `br l` we end up breaking inside the `l+1`th surrounding block, and throwing there. So if that `l+1`th surrounding block is a try, we end up throwing in its "try code", and thus correctly getting delegated to that try's catches.
191191

0 commit comments

Comments
 (0)