authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-22 13:22:40+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-23 09:44:36+02:00
logf8154905e7798aa0e884aa55e9336531f8c2daba
tree0e8f521c21031f09aa3dfca291af08a01f858da9
parente5c30eef1f338ed65325ddbfd4d631baef0d9b81

stage1: rename TypeInfo.FnArg to Fn.Param


3 files changed, 18 insertions(+), 17 deletions(-)

lib/std/builtin.zig+11-9
......@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {
346346 decls: []const Declaration,
347347 };
348348
349 /// This data structure is used by the Zig language code generation and
350 /// therefore must be kept in sync with the compiler implementation.
351 /// TODO rename to Param and put inside `Fn`.
352 pub const FnArg = struct {
353 is_generic: bool,
354 is_noalias: bool,
355 arg_type: ?type,
356 };
349 /// TODO deprecated use Fn.Param
350 pub const FnArg = Fn.Param;
357351
358352 /// This data structure is used by the Zig language code generation and
359353 /// therefore must be kept in sync with the compiler implementation.
......@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {
363357 is_generic: bool,
364358 is_var_args: bool,
365359 return_type: ?type,
366 args: []const FnArg,
360 args: []const Param,
361
362 /// This data structure is used by the Zig language code generation and
363 /// therefore must be kept in sync with the compiler implementation.
364 pub const Param = struct {
365 is_generic: bool,
366 is_noalias: bool,
367 arg_type: ?type,
368 };
367369 };
368370
369371 /// This data structure is used by the Zig language code generation and
src/stage1/ir.cpp+4-5
......@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1875018750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
1875118751 fields[4]->data.x_optional = return_type;
1875218752 }
18753 // args: []TypeInfo.FnArg
18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
18753 // args: []TypeInfo.Fn.Param
18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
1875518755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
1875618756 zig_unreachable();
1875718757 }
......@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1961419614 assert(args_arr->data.x_array.special == ConstArraySpecialNone);
1961519615 for (size_t i = 0; i < args_len; i++) {
1961619616 ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];
19617 assert(arg_value->type == ir_type_info_get_type(ira, "FnArg", nullptr));
1961819617 FnTypeParamInfo *info = &fn_type_id.param_info[i];
1961919618 Error err;
1962019619 bool is_generic;
1962119620 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
1962219621 return ira->codegen->invalid_inst_gen->value->type;
1962319622 if (is_generic) {
19624 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.is_generic must be false for @Type"));
19623 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.is_generic must be false for @Type"));
1962519624 return ira->codegen->invalid_inst_gen->value->type;
1962619625 }
1962719626 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_
1962919628 ZigType *type = get_const_field_meta_type_optional(
1963019629 ira, source_node, arg_value, "arg_type", 2);
1963119630 if (type == nullptr) {
19632 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.FnArg.arg_type must be non-null for @Type"));
19631 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.arg_type must be non-null for @Type"));
1963319632 return ira->codegen->invalid_inst_gen->value->type;
1963419633 }
1963519634 info->type = type;
test/compile_errors.zig+3-3
......@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {
450450 \\ .is_generic = true,
451451 \\ .is_var_args = false,
452452 \\ .return_type = u0,
453 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
453 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
454454 \\ },
455455 \\});
456456 \\comptime { _ = Foo; }
......@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {
466466 \\ .is_generic = false,
467467 \\ .is_var_args = true,
468468 \\ .return_type = u0,
469 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
469 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
470470 \\ },
471471 \\});
472472 \\comptime { _ = Foo; }
......@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {
482482 \\ .is_generic = false,
483483 \\ .is_var_args = false,
484484 \\ .return_type = null,
485 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
485 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
486486 \\ },
487487 \\});
488488 \\comptime { _ = Foo; }