Skip to content

Commit 6b34887

Browse files
authored
Zig master builtin type field changes (#18)
1 parent 193a210 commit 6b34887

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/parser.zig

+5-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn EnumCustomStringValues(comptime T: type, comptime contains_empty_enum: bo
134134

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

365-
if (@typeInfo(@TypeOf(expected)) != .ErrorSet) {
365+
const std_builtin_type_rename = comptime std.SemanticVersion.parse("0.14.0-dev.1346+31fef6f11") catch unreachable;
366+
const error_set_tag = comptime if (@import("builtin").zig_version.order(std_builtin_type_rename) == .lt) .ErrorSet else .error_set;
367+
368+
if (@typeInfo(@TypeOf(expected)) != error_set_tag) {
366369
const actual_from_slice = try std.json.parseFromSliceLeaky(T, arena, s, .{});
367370
try std.testing.expectEqualDeep(@as(T, expected), actual_from_slice);
368371

0 commit comments

Comments
 (0)