summaryrefslogtreecommitdiff
path: root/src/Messages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-21 14:35:15 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commitbc3d18d27f9fc1155db7fac3946c4d38774f9e65 (patch)
tree9178ce95952797f8a78b16c2b805e53368efb35a /src/Messages.zig
parent1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2 (diff)
downloadpardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.tar.gz
pardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.zip
Build with Zig 0.17
ghostty, libvaxis and uucode move to ghostty's 0.17 pins, cloud9 to its 0.17 main, SDL to castholm's release-3.4.x (3.4.18), zstbi and tree-sitter to forks with 0.17 build files (see build.zig.zon). A bare zig build copies the binaries into ~/.local/bin (-Dhome-install=false leaves it out): 0.17 keeps the prefix from build scripts. A terminal's edited copy goes when the program clears the screen. tinywin.snap is gone; perf baselines are re-recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Messages.zig')
-rw-r--r--src/Messages.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index 2314939f..b67a8402 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -519,20 +519,20 @@ pub fn errorWords(err: anyerror, buf: []u8) []const u8 {
/// A ZON parse failure in a person's words: the first error the parser
/// found and its line, `line 3: expected ','`.
pub fn zonWhy(diag: *const std.zon.parse.Diagnostics, buf: []u8) []const u8 {
- var errors = diag.iterateErrors();
- const first = errors.next() orelse return "not valid ZON";
- const loc = first.getLocation(diag);
- return std.fmt.bufPrint(buf, "line {d}: {f}", .{ loc.line + 1, first.fmtMessage(diag) }) catch "not valid ZON";
+ if (diag.errors.len == 0) return "not valid ZON";
+ const first = diag.errors[0];
+ return std.fmt.bufPrint(buf, "line {d}: {s}", .{ first.loc.line + 1, first.msg }) catch "not valid ZON";
}
test "errors are said in words, and a ZON failure names its line" {
var buf: [128]u8 = undefined;
try std.testing.expectEqualStrings("file not found", errorWords(error.FileNotFound, &buf));
try std.testing.expectEqualStrings("too large", errorWords(error.FileTooLarge, &buf));
- var diag: std.zon.parse.Diagnostics = .{};
- defer diag.deinit(std.testing.allocator);
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ var diag: std.zon.parse.Diagnostics = undefined;
const T = struct { a: u8 };
- try std.testing.expectError(error.ParseZon, std.zon.parse.fromSliceAlloc(T, std.testing.allocator, ".{\n .a = 1,\n .b = 2 }", &diag, .{}));
+ try std.testing.expectError(error.ParseZon, std.zon.parse.fromSlice(T, .{ .gpa = std.testing.allocator, .arena = arena.allocator(), .source = ".{\n .a = 1,\n .b = 2 }", .diagnostics = &diag }));
try std.testing.expect(std.mem.startsWith(u8, zonWhy(&diag, &buf), "line 3: "));
}