aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs/11179.zig
blob: 84fa6183f37934afed888096c64443678e9987d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const std = @import("std");
const Type = std.builtin.Type;

test "Tuple" {
    const fields_list = fields(@TypeOf(.{}));
    if (fields_list.len != 0)
        @compileError("Argument count mismatch");
}

pub fn fields(comptime T: type) switch (@typeInfo(T)) {
    .Struct => []const Type.StructField,
    else => unreachable,
} {
    return switch (@typeInfo(T)) {
        .Struct => |info| info.fields,
        else => unreachable,
    };
}