mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
This was a poor naming choice; these are parameters, not arguments. Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
35 lines
754 B
Zig
35 lines
754 B
Zig
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);
|
|
}
|