diff options
| author | Meghan <hello@nektro.net> | 2023-05-19 12:48:28 -0700 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-05-20 11:21:06 +0300 |
| commit | 7077e90b3f8991c844deb08a16ad3f4e0569398f (patch) | |
| tree | cb6072804e43987cbb563bf3d5016c72ca986e94 /lib/std/meta.zig | |
| parent | ccfb0d408d5ffb40f77a8ad1fb57f0bb854583ad (diff) | |
| download | zig-7077e90b3f8991c844deb08a16ad3f4e0569398f.tar.gz zig-7077e90b3f8991c844deb08a16ad3f4e0569398f.zip | |
std.meta: allow ArgsTuple to be used on functions with comptime parameters
any comptime parameter sets `.is_generic` to be true but in many cases these will still be discrete types available in `.params`
Diffstat (limited to 'lib/std/meta.zig')
| -rw-r--r-- | lib/std/meta.zig | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig index cd83061d53..8adba2439a 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1037,14 +1037,12 @@ pub fn ArgsTuple(comptime Function: type) type { @compileError("ArgsTuple expects a function type"); const function_info = info.Fn; - if (function_info.is_generic) - @compileError("Cannot create ArgsTuple for generic function"); if (function_info.is_var_args) @compileError("Cannot create ArgsTuple for variadic function"); var argument_field_list: [function_info.params.len]type = undefined; inline for (function_info.params, 0..) |arg, i| { - const T = arg.type.?; + const T = arg.type orelse @compileError("cannot create ArgsTuple for function with an 'anytype' parameter"); argument_field_list[i] = T; } @@ -1116,6 +1114,7 @@ test "ArgsTuple" { TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8)); TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn)); TupleTester.assertTuple(.{ u32, f16, []const u8, void }, ArgsTuple(fn (a: u32, b: f16, c: []const u8, void) noreturn)); + TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); } test "Tuple" { |
