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

Commit 2d732e6

Browse files
authored
Miscellaneous fixes to formal overview document. (#231)
In particular: - We dropped `kind` property of labels, and went for labels of the form `catch^? [t*]` after all. - Changed some `^n` to `*` where appropriate. - Removed occurrences of "we ..." formulations.
1 parent c5a8a43 commit 2d732e6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ mod ::= 'module' ... tag*
3838

3939
### Validation Contexts: Tagtypes and modified Labels
4040

41-
To verify that the `rethrow l` instruction refers to a label surrounding the instructions of a catch block (call this a catch-label), we introduce a `kind` attribute to labels in the validation context, which is set to `catch` when the label is a catch-label and empty otherwise.
41+
To verify that the `rethrow l` instruction refers to a label surrounding the instructions of a catch block (call this a catch-label), an optional `catch` specifier is introduced to labels in the validation context.
4242

4343
```
44-
labelkind ::= 'catch'
4544
labeltype ::= 'catch'? resulttype
4645
```
4746

@@ -67,7 +66,7 @@ C.tags[x] = [t*]→[]
6766
C ⊢ throw x : [t1* t*]→[t2*]
6867
6968
70-
C.labels[l].kind = catch
69+
C.labels[l] = catch [t*]
7170
----------------------------
7271
C ⊢ rethrow l : [t1*]→[t2*]
7372
@@ -116,12 +115,12 @@ m ::= {..., 'tags' tagaddr*}
116115

117116
```
118117
instr ::= ... | 'throw' tagaddr | 'catch'{ tagaddr? instr* }* instr* 'end'
119-
| 'delegate'{ labelidx } instr* 'end' | 'caught'{ tagaddr val^n } instr* 'end'
118+
| 'delegate'{ labelidx } instr* 'end' | 'caught'{ tagaddr val* } instr* 'end'
120119
```
121120

122121
#### Block Contexts and Label Kinds
123122

124-
So far block contexts are only used in the reduction of `br l` and `return`, and only include labels or values on the stack on the left side of the hole `[_]`. If we want to be able to break jumping over try-catch and try-delegate blocks, we must allow for the new administrative control instructions to appear after labels in block contexts.
123+
So far block contexts are only used in the reduction of `br l` and `return`, and only include labels or values on the stack on the left side of the hole `[_]`. To be able to break jumping over try-catch and try-delegate blocks, the new administrative control instructions must be allowed to appear after labels in block contexts.
125124

126125
```
127126
B^0 ::= val* '[_]' instr* | val* C^0 instr*
@@ -189,9 +188,9 @@ label_m{} B^l[ delegate{l} T[val^n (throw a)] end ] end
189188
↪ val^n (throw a)
190189
```
191190

192-
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.
191+
Note that the last reduction step above is similar to the reduction of `br l` [1], the entire `delegate{l}...end` is seen as a `br l` immediately followed by a throw.
193192

194-
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.
193+
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` the instruction ends up breaking inside the `l+1`th surrounding block, and throwing there. So if that `l+1`th surrounding block is a try, the exception is thrown in the "try code", and thus correctly getting delegated to that try's catches.
195194

196195
- [1] [The execution step for `br l`](https://webassembly.github.io/spec/core/exec/instructions.html#xref-syntax-instructions-syntax-instr-control-mathsf-br-l)
197196
- [2] The label that always wraps `delegate{l}...end` can be thought of as "level -1" and cannot be referred to by the delegate's label index `l`.
@@ -219,7 +218,7 @@ S ⊢ tag a : tag [t0*]→[]
219218
(val:t0)*
220219
S;C, labels (catch [t*]) ⊢ instr* : []→[t*]
221220
----------------------------------------------------------
222-
S;C, labels [t*] ⊢ caught{a val^n} instr* end : []→[t*]
221+
S;C, labels [t*] ⊢ caught{a val^*} instr* end : []→[t*]
223222
```
224223

225224
## TODO Uncaught Exceptions

0 commit comments

Comments
 (0)