You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
- 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`.
- Fixes a location of `$label2` in a test.
- Removes `_m` from `catch` and `caught` administrative instructions in
Exceptions-formal-examples.md. They were only removed in the overview.
Copy file name to clipboardExpand all lines: proposals/exception-handling/Exceptions-formal-examples.md
+49-49
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Note that the block contexts and throw contexts given for the reductions are the
20
20
21
21
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`.
22
22
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 `[]→[]`.
24
24
25
25
```
26
26
(tag $x)
@@ -63,31 +63,31 @@ Take the frame `F = (locals i32.const 0, module m)`. We have:
Use the trivial throw context `T` again, this time to match the throw to the `catch_1`.
128
+
Use the trivial throw context `T` again, this time to match the throw to the `catch`.
129
129
130
130
```
131
131
↪ F'; (label_1{}
132
-
(catch_1{ a_x (local.get 0) }
132
+
(catch{ a_x (local.get 0) }
133
133
T[ (throw a_x) ] end) end)
134
134
135
135
↪ F'; (label_1{}
136
-
(caught_1{ a_x ε }
136
+
(caught{ a_x ε }
137
137
(local.get 0) end) end)
138
138
139
139
↪ F'; (label_1{}
140
-
(caught_1{ a_x ε }
140
+
(caught{ a_x ε }
141
141
(i32.const 27) end) end)
142
142
143
143
↪ F'; (label_1{}
@@ -153,11 +153,11 @@ Use the trivial throw context `T` again, this time to match the throw to the `ca
153
153
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`.
154
154
155
155
```
156
-
try
156
+
try $label2
157
157
val_x
158
-
throw x
159
-
catch x
160
-
try $label2
158
+
throw $x
159
+
catch $x
160
+
try
161
161
val_y
162
162
throw y
163
163
catch_all
@@ -177,8 +177,8 @@ Folded it looks as follows.
177
177
(try
178
178
(do
179
179
val_x
180
-
(throw x))
181
-
(catch x ;; <--- (rethrow 2) targets this catch.
180
+
(throw $x))
181
+
(catch $x ;; <--- (rethrow 2) targets this catch.
182
182
(try
183
183
(do
184
184
val_y
@@ -196,13 +196,13 @@ In the above example, all thrown exceptions get caught and the first one gets re
196
196
197
197
```
198
198
(label_0{}
199
-
(caught_0{ a_x val_x } ;; <---- The exception rethrown by `rethrow 2` below.
199
+
(caught{ a_x val_x } ;; <---- The exception rethrown by `rethrow 2` below.
200
200
val_x
201
201
(label_0{}
202
-
(caught_0{ a_y val_y }
202
+
(caught{ a_y val_y }
203
203
;; The catch_all does not leave val_y here.
204
204
(label_0{}
205
-
(caught_0{ a_z val_z }
205
+
(caught{ a_z val_z }
206
206
val_z
207
207
;; (rethrow 2) puts val_x and the throw below.
208
208
val_x
@@ -222,7 +222,7 @@ This reduces to `val_x (throw a_x)`, throwing to the caller.
222
222
(func
223
223
try $label0
224
224
rethrow $label0 ;; cannot be done, because it's not within catch below
225
-
catch x
225
+
catch $x
226
226
end)
227
227
```
228
228
@@ -237,7 +237,7 @@ This is a validation error (no catch block at given rethrow depth).
237
237
```
238
238
(try $l
239
239
(do
240
-
(throw x))
240
+
(throw $x))
241
241
(delegate $l))
242
242
```
243
243
@@ -252,23 +252,23 @@ try $label1
252
252
try
253
253
try $label0
254
254
try
255
-
throw x
255
+
throw $x
256
256
delegate $label0 ;; delegate 0
257
257
delegate $label1 ;; delegate 1
258
258
catch_all
259
259
end
260
-
catch x
260
+
catch $x
261
261
instr*
262
262
end
263
263
```
264
264
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:
266
266
267
267
```
268
268
(label_0{}
269
-
(catch_0{ a_x instr* }
269
+
(catch{ a_x instr* }
270
270
(label_0{}
271
-
(catch_0{ ε ε }
271
+
(catch{ ε ε }
272
272
(label_0{}
273
273
(delegate{ 1 }
274
274
(label_0{}
@@ -280,26 +280,26 @@ The `delegate{ 0 }` reduces using the trivial throw and block contexts to:
280
280
281
281
```
282
282
(label_0{}
283
-
(catch_0{ a_x instr* }
283
+
(catch{ a_x instr* }
284
284
(label_0{}
285
-
(catch_0{ ε ε }
285
+
(catch{ ε ε }
286
286
(label_0{}
287
287
(delegate{ 1 }
288
288
(throw a_x) end) end) end) end) end) end)
289
289
```
290
290
291
-
The `delegate{ 1 }` reduces using the trivial throw context and the block context `B^1 := (catch_0{ ε ε } (label_0{} [_] end) end)` to the following:
291
+
The `delegate{ 1 }` reduces using the trivial throw context and the block context `B^1 := (catch{ ε ε } (label_0{} [_] end) end)` to the following:
292
292
293
293
```
294
294
(label_0{}
295
-
(catch_0{ a_x instr* }
295
+
(catch{ a_x instr* }
296
296
(throw a_x) end) end)
297
297
```
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.
299
299
300
300
```
301
301
(label_0 {}
302
-
(caught_0{a_x}
302
+
(caught{a_x}
303
303
instr* end) end)
304
304
```
305
305
@@ -310,7 +310,7 @@ The thrown exception is (eventually) caught by the outer try's `catch x`, so the
310
310
```
311
311
try (result i32)
312
312
try $label0
313
-
throw x
313
+
throw $x
314
314
catch_all
315
315
try
316
316
throw y
@@ -328,7 +328,7 @@ In folded form this is:
328
328
(do
329
329
(try
330
330
(do
331
-
(throw x))
331
+
(throw $x))
332
332
(catch_all
333
333
(try
334
334
(do
@@ -342,9 +342,9 @@ When it's time to reduce `(throw y)`, the reduction looks as follows.
342
342
343
343
```
344
344
(label_1{}
345
-
(catch_1{ ε (i32.const 4) }
345
+
(catch{ ε (i32.const 4) }
346
346
(label_0{}
347
-
(caught_0{ a_x ε }
347
+
(caught{ a_x ε }
348
348
(label_0{}
349
349
(delegate{ 0 }
350
350
(throw a_y) end) end) end) end) end) end)
@@ -354,17 +354,17 @@ For `B^0 := [_] := T`, the above is the same as the following.
Copy file name to clipboardExpand all lines: proposals/exception-handling/Exceptions-formal-overview.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -185,7 +185,7 @@ label_m{} B^l[ delegate{l} T[val^n (throw a)] end ] end
185
185
↪ val^n (throw a)
186
186
```
187
187
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.
189
189
190
190
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.
0 commit comments