ERR: use the catch match-body form in examples/235

The preceding parser fix (parenthesized match-arm value vs payload capture)
fully enables `catch e == { case .X: (tuple) }` — both scalar and tuple arm
values. Tuple literals in statement/binding position already worked, so the
match-body form runs end-to-end.

Add a `classify` to examples/235 exercising multi-value catch match-body with
per-tag value-tuple arms; exit 164 -> 170. Regenerate the snapshot.

(Corrects an earlier note that wrongly claimed a separate "issue 0059" blocked
the tuple match-body form — no such issue exists; the capture-parse bug was the
whole problem.)

Gates: zig build, zig build test, 273/273 examples.
This commit is contained in:
agra
2026-06-01 00:16:39 +03:00
parent d4b1248f65
commit f96bcc4fe4
3 changed files with 15 additions and 3 deletions

View File

@@ -30,6 +30,16 @@ safe :: (n: s32) -> s32 {
return v + b;
}
// Multi-value `catch` match-body — per-tag dispatch, each arm a value-tuple.
classify :: (n: s32) -> s32 {
v, b := parse(n) catch e == {
case .Bad: (1, 1);
case .Empty: (2, 2);
else: (9, 9);
};
return v + b;
}
// Multi-value `or (tuple)` value-terminator (absorbs the failure).
ortest :: (n: s32) -> s32 {
v, b := parse(n) or (7, 8);
@@ -57,8 +67,10 @@ main :: () -> s32 {
r = r + safe(5); // (10, 6) → 16
r = r + safe(-1); // Bad → catch → (40, 50) → 90
r = r + classify(-1); // Bad → match-body → (1, 1) → 2
r = r + classify(0); // Empty → match-body → (2, 2) → 4
r = r + ortest(0); // Empty → or → (7, 8) → 15
print("multi-value result: {}\n", r); // 16+4+18+5+16+90+15 = 164
print("multi-value result: {}\n", r); // 16+4+18+5+16+90+2+4+15 = 170
return r;
}