aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-23 23:28:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-23 23:28:05 -0700
commit2af69710a7b1513f3540ae0e1178cb5f3948204d (patch)
tree9f8aa5fd7d80ec976a5355348e7b3a6347caf1b5 /lib/std/meta.zig
parentaca42c62598523b92de7a51d3d84f2f2e5146536 (diff)
downloadzig-2af69710a7b1513f3540ae0e1178cb5f3948204d.tar.gz
zig-2af69710a7b1513f3540ae0e1178cb5f3948204d.zip
stage2: fix some generics issues
* std.meta: correct use of `default_value` in reification. stage1 accepted a wrong type for `null`. * Sema: after instantiating a generic function, if the return type ends up being a comptime-known type, then we return an error, undoing the generic function instantiation, and making a comptime function call instead. - We also needed to clean up the dependency graph in this case. * Sema: reified enums set tag_ty_inferred to false since an integer tag type is provided. This is a limitation of the `@Type` builtin which will be addressed with #10710. * Sema: fix resolveInferredErrorSet incorrectly calling ensureFuncBodyAnalyzed on generic functions.
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 7be06e0fd1..4e03eb602b 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -569,10 +569,10 @@ test "std.meta.fieldNames" {
}
pub fn FieldEnum(comptime T: type) type {
- const fieldInfos = fields(T);
- var enumFields: [fieldInfos.len]std.builtin.Type.EnumField = undefined;
+ const field_infos = fields(T);
+ var enumFields: [field_infos.len]std.builtin.Type.EnumField = undefined;
var decls = [_]std.builtin.Type.Declaration{};
- inline for (fieldInfos) |field, i| {
+ inline for (field_infos) |field, i| {
enumFields[i] = .{
.name = field.name,
.value = i,
@@ -581,7 +581,7 @@ pub fn FieldEnum(comptime T: type) type {
return @Type(.{
.Enum = .{
.layout = .Auto,
- .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1),
+ .tag_type = std.math.IntFittingRange(0, field_infos.len - 1),
.fields = &enumFields,
.decls = &decls,
.is_exhaustive = true,
@@ -966,7 +966,7 @@ pub fn ArgsTuple(comptime Function: type) type {
argument_field_list[i] = .{
.name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,
.field_type = T,
- .default_value = @as(?T, null),
+ .default_value = null,
.is_comptime = false,
.alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0,
};
@@ -997,7 +997,7 @@ pub fn Tuple(comptime types: []const type) type {
tuple_fields[i] = .{
.name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,
.field_type = T,
- .default_value = @as(?T, null),
+ .default_value = null,
.is_comptime = false,
.alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0,
};