From 4f173519411a0f78e3f739577569bf1ef1c5ff77 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:10:39 +0200 Subject: [PATCH] explicitly specify error set of `std.json.stringify` --- lib/std/json/stringify.zig | 2 +- lib/std/json/stringify_test.zig | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/std/json/stringify.zig b/lib/std/json/stringify.zig index c8084a7b61f0..17ab3a1eb548 100644 --- a/lib/std/json/stringify.zig +++ b/lib/std/json/stringify.zig @@ -140,7 +140,7 @@ pub fn stringify( value: anytype, options: StringifyOptions, out_stream: anytype, -) !void { +) @TypeOf(out_stream).Error!void { const T = @TypeOf(value); switch (@typeInfo(T)) { .Float, .ComptimeFloat => { diff --git a/lib/std/json/stringify_test.zig b/lib/std/json/stringify_test.zig index 7fff97f13e58..19f8f06e5e87 100644 --- a/lib/std/json/stringify_test.zig +++ b/lib/std/json/stringify_test.zig @@ -260,23 +260,6 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions if (vos.expected_remaining.len > 0) return error.NotEnoughData; } -test "stringify struct with custom stringify that returns a custom error" { - var ret = stringify(struct { - field: Field = .{}, - - pub const Field = struct { - field: ?[]*Field = null, - - const Self = @This(); - pub fn jsonStringify(_: Self, _: StringifyOptions, _: anytype) error{CustomError}!void { - return error.CustomError; - } - }; - }{}, StringifyOptions{}, std.io.null_writer); - - try std.testing.expectError(error.CustomError, ret); -} - test "stringify alloc" { const allocator = std.testing.allocator; const expected =