| author | |
| committer | |
| log | f8154905e7798aa0e884aa55e9336531f8c2daba |
| tree | 0e8f521c21031f09aa3dfca291af08a01f858da9 |
| parent | e5c30eef1f338ed65325ddbfd4d631baef0d9b81 |
3 files changed, 18 insertions(+), 17 deletions(-)
lib/std/builtin.zig+11-9| ... | ... | @@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) { |
| 346 | 346 | decls: []const Declaration, |
| 347 | 347 | }; |
| 348 | 348 | |
| 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; | |
| 357 | 351 | |
| 358 | 352 | /// This data structure is used by the Zig language code generation and |
| 359 | 353 | /// therefore must be kept in sync with the compiler implementation. |
| ... | ... | @@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) { |
| 363 | 357 | is_generic: bool, |
| 364 | 358 | is_var_args: bool, |
| 365 | 359 | 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 | }; | |
| 367 | 369 | }; |
| 368 | 370 | |
| 369 | 371 | /// 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 |
| 18750 | 18750 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| 18751 | 18751 | fields[4]->data.x_optional = return_type; |
| 18752 | 18752 | } |
| 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); | |
| 18755 | 18755 | if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) { |
| 18756 | 18756 | zig_unreachable(); |
| 18757 | 18757 | } |
| ... | ... | @@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 19614 | 19614 | assert(args_arr->data.x_array.special == ConstArraySpecialNone); |
| 19615 | 19615 | for (size_t i = 0; i < args_len; i++) { |
| 19616 | 19616 | 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)); | |
| 19618 | 19617 | FnTypeParamInfo *info = &fn_type_id.param_info[i]; |
| 19619 | 19618 | Error err; |
| 19620 | 19619 | bool is_generic; |
| 19621 | 19620 | if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic))) |
| 19622 | 19621 | return ira->codegen->invalid_inst_gen->value->type; |
| 19623 | 19622 | 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")); | |
| 19625 | 19624 | return ira->codegen->invalid_inst_gen->value->type; |
| 19626 | 19625 | } |
| 19627 | 19626 | 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_ |
| 19629 | 19628 | ZigType *type = get_const_field_meta_type_optional( |
| 19630 | 19629 | ira, source_node, arg_value, "arg_type", 2); |
| 19631 | 19630 | 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")); | |
| 19633 | 19632 | return ira->codegen->invalid_inst_gen->value->type; |
| 19634 | 19633 | } |
| 19635 | 19634 | info->type = type; |
test/compile_errors.zig+3-3| ... | ... | @@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 450 | 450 | \\ .is_generic = true, |
| 451 | 451 | \\ .is_var_args = false, |
| 452 | 452 | \\ .return_type = u0, |
| 453 | \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{}, | |
| 453 | \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{}, | |
| 454 | 454 | \\ }, |
| 455 | 455 | \\}); |
| 456 | 456 | \\comptime { _ = Foo; } |
| ... | ... | @@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 466 | 466 | \\ .is_generic = false, |
| 467 | 467 | \\ .is_var_args = true, |
| 468 | 468 | \\ .return_type = u0, |
| 469 | \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{}, | |
| 469 | \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{}, | |
| 470 | 470 | \\ }, |
| 471 | 471 | \\}); |
| 472 | 472 | \\comptime { _ = Foo; } |
| ... | ... | @@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 482 | 482 | \\ .is_generic = false, |
| 483 | 483 | \\ .is_var_args = false, |
| 484 | 484 | \\ .return_type = null, |
| 485 | \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{}, | |
| 485 | \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{}, | |
| 486 | 486 | \\ }, |
| 487 | 487 | \\}); |
| 488 | 488 | \\comptime { _ = Foo; } |