Commit f8154905e7
Changed files (3)
lib/std/builtin.zig
@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {
decls: []const Declaration,
};
- /// This data structure is used by the Zig language code generation and
- /// therefore must be kept in sync with the compiler implementation.
- /// TODO rename to Param and put inside `Fn`.
- pub const FnArg = struct {
- is_generic: bool,
- is_noalias: bool,
- arg_type: ?type,
- };
+ /// TODO deprecated use Fn.Param
+ pub const FnArg = Fn.Param;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {
is_generic: bool,
is_var_args: bool,
return_type: ?type,
- args: []const FnArg,
+ args: []const Param,
+
+ /// This data structure is used by the Zig language code generation and
+ /// therefore must be kept in sync with the compiler implementation.
+ pub const Param = struct {
+ is_generic: bool,
+ is_noalias: bool,
+ arg_type: ?type,
+ };
};
/// This data structure is used by the Zig language code generation and
src/stage1/ir.cpp
@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
fields[4]->data.x_optional = return_type;
}
- // args: []TypeInfo.FnArg
- ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
+ // args: []TypeInfo.Fn.Param
+ ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
zig_unreachable();
}
@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
assert(args_arr->data.x_array.special == ConstArraySpecialNone);
for (size_t i = 0; i < args_len; i++) {
ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];
- assert(arg_value->type == ir_type_info_get_type(ira, "FnArg", nullptr));
FnTypeParamInfo *info = &fn_type_id.param_info[i];
Error err;
bool is_generic;
if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
return ira->codegen->invalid_inst_gen->value->type;
if (is_generic) {
- ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.is_generic must be false for @Type"));
+ ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.is_generic must be false for @Type"));
return ira->codegen->invalid_inst_gen->value->type;
}
if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))
@@ -19629,7 +19628,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
ZigType *type = get_const_field_meta_type_optional(
ira, source_node, arg_value, "arg_type", 2);
if (type == nullptr) {
- ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.arg_type must be non-null for @Type"));
+ ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.arg_type must be non-null for @Type"));
return ira->codegen->invalid_inst_gen->value->type;
}
info->type = type;
test/compile_errors.zig
@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ .is_generic = true,
\\ .is_var_args = false,
\\ .return_type = u0,
- \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
+ \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
\\ },
\\});
\\comptime { _ = Foo; }
@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ .is_generic = false,
\\ .is_var_args = true,
\\ .return_type = u0,
- \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
+ \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
\\ },
\\});
\\comptime { _ = Foo; }
@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ .is_generic = false,
\\ .is_var_args = false,
\\ .return_type = null,
- \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
+ \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
\\ },
\\});
\\comptime { _ = Foo; }