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/colors.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/colors.zig') diff --git a/src/colors.zig b/src/colors.zig index 65fd4056..f9e5495f 100644 --- a/src/colors.zig +++ b/src/colors.zig @@ -673,10 +673,10 @@ fn themeFileError(p: *Pardes, request: ThemeFileRequest, err: anyerror) void { } fn themeFileFailure(p: *Pardes, request: ThemeFileRequest, why: []const u8) void { - var said: [520]u8 = undefined; + var said: pardes.Kind.Buf(520) = .{}; var cut: [200]u8 = undefined; const path = @import("ninep/tree.zig").fitErr(request.path, &cut); - p.reportFailure(request.pane, std.fmt.bufPrint(&said, "theme file {s}: {s}", .{ path, why }) catch unreachable); // two 200-byte parts fit 520 + p.reportFailure(request.pane, said.print("theme file {s}: {s}", .{ path, why })); revertThemeFile(p); } @@ -778,7 +778,7 @@ pub fn themesNear(buf: []u8, name: []const u8) []const u8 { fn putName(w: *std.Io.Writer, cap: usize, name: []const u8) bool { const sep: []const u8 = if (w.buffered().len > 0) " " else ""; if (w.buffered().len + sep.len + name.len > cap) return false; - w.print("{s}{s}", .{ sep, name }) catch unreachable; // fits: checked above + w.print("{s}{s}", .{ sep, name }) catch return false; return true; } -- cgit v1.3