Open and answer this issue on GitHub.
ready · opened 2026-10-28 · updated 2026-10-28 · 0 comments
A handler that tells failures apart writes catch { match error { … } }, two blocks one inside the other. ADR-catch-1 decides a short form: a catch block whose first item is an arm is that match:
let re = regex::dynamic(p) catch {
regex::Error => {
eprintln(f"{error}")
return
}
else => throw error
}
Specification: Part I 7, the paragraph after a match over error is complete….
Came up on 2026-10-28 while building #673 step 1: catching regex::Error by its name showed that ADR-357 (a type named by its bare name or path covers that member of the error set) was accepted but not built, which is being built now (brief docs/briefs/b673b-catch-by-struct-type.md). The owner found the nested catch { match error { … } } heavy and asked for a shorter form that keeps every catch written today. Options weighed in the record: arms directly in the block (chosen), catch match, Java/Swift clauses per type, a new keyword.
catch block whose first item is an arm means catch { match error { … } } with the same arms, under the same rules: the patterns of Part I 3.4, a type by its path or bare name (ADR-357 D1), completeness and NK1151, a fatal error taken only by name (ADR-345 D2); its value is the arm’s.Needs ADR-357 built (D1 and D5).
catch block whose first item is pattern => parses as arms; the result is the same tree as catch { match error { … } }, so checker and lowering need nothing new. A block that mixes statements and arms is refused where the form changes, with a message that names the two forms.tests/compiler/tests/): the short form with one type, with two types each named, with else => throw error; an incomplete short form refused with NK1151 (.stderr); a fatal error passing a short form that does not name it; a mixed block refused (.stderr); the long form unchanged beside it.The commit that builds step 3 says Fixes #<this issue>.