From f8154905e7798aa0e884aa55e9336531f8c2daba Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 22 Feb 2022 13:22:40 +0200 Subject: [PATCH] stage1: rename TypeInfo.FnArg to Fn.Param --- lib/std/builtin.zig | 20 +++++++++++--------- src/stage1/ir.cpp | 9 ++++----- test/compile_errors.zig | 6 +++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index dda8d846fa..b4d751ae30 100644 --- a/lib/std/builtin.zig +++ b/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 diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 3ac1ddb51c..217a09d924 100644 --- a/src/stage1/ir.cpp +++ b/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; diff --git a/test/compile_errors.zig b/test/compile_errors.zig index d1971e46bb..580c525dba 100644 --- a/test/compile_errors.zig +++ b/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; }