Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn EnumCustomStringValues(comptime T: type, comptime contains_empty_enum: bo

const kvs = build_kvs: {
const KV = struct { []const u8, T };
const fields = @typeInfo(T).Union.fields;
const fields = std.meta.fields(T);
var kvs_array: [fields.len - 1]KV = undefined;
for (fields[0 .. fields.len - 1], &kvs_array) |field, *kv| {
if (contains_empty_enum and std.mem.eql(u8, field.name, "empty")) {
Expand Down Expand Up @@ -362,7 +362,10 @@ fn expectParseEqual(comptime T: type, comptime expected: anytype, s: []const u8)
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();

if (@typeInfo(@TypeOf(expected)) != .ErrorSet) {
const std_builtin_type_rename = comptime std.SemanticVersion.parse("0.14.0-dev.1346+31fef6f11") catch unreachable;
const error_set_tag = comptime if (@import("builtin").zig_version.order(std_builtin_type_rename) == .lt) .ErrorSet else .error_set;

if (@typeInfo(@TypeOf(expected)) != error_set_tag) {
const actual_from_slice = try std.json.parseFromSliceLeaky(T, arena, s, .{});
try std.testing.expectEqualDeep(@as(T, expected), actual_from_slice);

Expand Down