Skip to content

Commit

Permalink
Zig master builtin type field changes (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mochalins authored Aug 31, 2024
1 parent 193a210 commit 6b34887
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 6b34887

Please sign in to comment.