diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-03-05 12:39:32 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-04-12 12:06:19 -0400 |
| commit | ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0 (patch) | |
| tree | 3f7899bf6231500782af185ffe701ee66793e226 /lib/std/meta.zig | |
| parent | 602029bb2fb78048e46136784e717b57b8de8f2c (diff) | |
| download | zig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.tar.gz zig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.zip | |
Zir: implement explicit block_comptime instruction
Resolves: #7056
Diffstat (limited to 'lib/std/meta.zig')
| -rw-r--r-- | lib/std/meta.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 07f42075b4..3aca23b267 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -549,14 +549,14 @@ test "std.meta.FieldType" { } pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { - comptime { + return comptime blk: { const fieldInfos = fields(T); var names: [fieldInfos.len][]const u8 = undefined; for (fieldInfos, 0..) |field, i| { names[i] = field.name; } - return &names; - } + break :blk &names; + }; } test "std.meta.fieldNames" { @@ -590,14 +590,14 @@ test "std.meta.fieldNames" { /// Given an enum or error set type, returns a pointer to an array containing all tags for that /// enum or error set. pub fn tags(comptime T: type) *const [fields(T).len]T { - comptime { + return comptime blk: { const fieldInfos = fields(T); var res: [fieldInfos.len]T = undefined; for (fieldInfos, 0..) |field, i| { res[i] = @field(T, field.name); } - return &res; - } + break :blk &res; + }; } test "std.meta.tags" { |
