From 88adecd0f9a6e2fd9de65d0f1852bbde1e183590 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 2 Jun 2026 14:21:46 -0700 Subject: [PATCH] move the @errorCast calls to the catch block to preserve error return trace mitigates zig/issues/20177 --- json.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json.zig b/json.zig index c0779fb61319a564dd998c62c906ff7eaefb50fa..58d6782c71b04fd6292112541384940d68e2cdf9 100644 --- a/json.zig +++ b/json.zig @@ -40,7 +40,7 @@ pub fn parseFromSlice(alloc: std.mem.Allocator, path: string, input: string, opt } fn parseElementPrecise(alloc: std.mem.Allocator, p: *Parser, comptime E: type) E!ValueIndex { - return @errorCast(parseElement(alloc, p)); + return parseElement(alloc, p) catch |err| @errorCast(err); } fn parseElement(alloc: std.mem.Allocator, p: *Parser) anyerror!ValueIndex { @@ -433,7 +433,7 @@ pub const Document = struct { pub fn stringify(this: *const Document, writer: anytype, space: Space, indent: u8) Instance(@TypeOf(writer)).WriteError!void { const fill = space.fill(); try writer.writeNTimes(fill, indent); - return @errorCast(this.root.stringify(writer, space, indent)); + return this.root.stringify(writer, space, indent) catch |err| @errorCast(err); } }; -- 2.54.0