From a821fe82d8de3d407ebe104358b97719bd983727 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 13:16:18 -0300 Subject: idioms #19, unreachable only where the type bounds it: the prints that carry a path, a name, a miss or a reason (Core's shell and Dump words, colors' theme file, look's misses and refusals) cut through Kind.Buf at their old size, the header texts flatSurface could still fail on and colors' putName handle the failure again, and every kept site (integers, a same-statement cut into a [K + room] buffer, the hashing and discarding writers) says its bound on its line Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/keys.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/keys.zig') diff --git a/src/keys.zig b/src/keys.zig index ece79651..5ebdc046 100644 --- a/src/keys.zig +++ b/src/keys.zig @@ -91,7 +91,7 @@ pub fn questionChoices(p: *const Pardes, id: usize, buf: []u8) ?[]const u8 { var w = std.Io.Writer.fixed(buf); for (ask.offered, 0..) |serial, i| if (serial != 0) { if (w.buffered().len > 0) w.writeByte(' ') catch unreachable; // 26 letters and spaces fit 64 - w.writeByte(@intCast('a' + i)) catch unreachable; + w.writeByte(@intCast('a' + i)) catch unreachable; // [26]u32 offered: 51 bytes fit 64 }; return w.buffered(); }, @@ -112,7 +112,7 @@ pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool { if (questionChoices(p, id, &offered)) |choices| { const chosen: ?u8 = if (choice) |c| (if (std.mem.indexOfScalar(u8, choices, c) != null and c != ' ') c else null) else null; var rec: [32]u8 = undefined; - ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch unreachable); // a u32 and a letter + ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch unreachable); // a u32 and a letter fit 32 } switch (asked.prompt) { .repl_choice => { -- cgit v1.3