1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const std = @import("std");
const builtin = std.builtin;
const expect = std.testing.expect;
const info = .{
.args = [_]builtin.Type.Error{
.{ .name = "bar" },
},
};
const Foo = @Type(.{
.ErrorSet = &info.args,
});
test "ErrorSet comptime_field_ptr" {
try expect(Foo == error{bar});
}
const fn_info = .{
.params = [_]builtin.Type.Fn.Param{
.{ .is_generic = false, .is_noalias = false, .type = u8 },
},
};
const Bar = @Type(.{
.Fn = .{
.calling_convention = .Unspecified,
.alignment = 0,
.is_generic = false,
.is_var_args = false,
.return_type = void,
.params = &fn_info.params,
},
});
test "fn comptime_field_ptr" {
try expect(@typeInfo(Bar) == .Fn);
}
|