authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-23 16:10:17-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-02-23 16:10:17-05:00
logecf56d85efa227acf1bd9cab9ad2d5af05f7efe5
treed83ccefd98555c33d492273cb20f86fe78965416
parent88d1258e08e668e620d5f8f4681315e555acbcd2
parentab4d693cfc82465c42021ba6f18c65fdd5f969e6
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #10969 from Vexu/stage2

stage2: fn typeinfo params

9 files changed, 127 insertions(+), 56 deletions(-)

lib/std/builtin.zig+11-9
...@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {...@@ -346,14 +346,8 @@ pub const TypeInfo = union(enum) {
346 decls: []const Declaration,346 decls: []const Declaration,
347 };347 };
348348
349 /// This data structure is used by the Zig language code generation and349 /// TODO deprecated use Fn.Param
350 /// therefore must be kept in sync with the compiler implementation.350 pub const FnArg = Fn.Param;
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 };
357351
358 /// This data structure is used by the Zig language code generation and352 /// This data structure is used by the Zig language code generation and
359 /// therefore must be kept in sync with the compiler implementation.353 /// therefore must be kept in sync with the compiler implementation.
...@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {...@@ -363,7 +357,15 @@ pub const TypeInfo = union(enum) {
363 is_generic: bool,357 is_generic: bool,
364 is_var_args: bool,358 is_var_args: bool,
365 return_type: ?type,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 };
368370
369 /// This data structure is used by the Zig language code generation and371 /// This data structure is used by the Zig language code generation and
lib/std/math.zig+4-3
...@@ -947,7 +947,7 @@ fn testRem() !void {...@@ -947,7 +947,7 @@ fn testRem() !void {
947/// Result is an unsigned integer.947/// Result is an unsigned integer.
948pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {948pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
949 .ComptimeInt => comptime_int,949 .ComptimeInt => comptime_int,
950 .Int => |intInfo| std.meta.Int(.unsigned, intInfo.bits),950 .Int => |int_info| std.meta.Int(.unsigned, int_info.bits),
951 else => @compileError("absCast only accepts integers"),951 else => @compileError("absCast only accepts integers"),
952} {952} {
953 switch (@typeInfo(@TypeOf(x))) {953 switch (@typeInfo(@TypeOf(x))) {
...@@ -958,8 +958,9 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {...@@ -958,8 +958,9 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
958 return x;958 return x;
959 }959 }
960 },960 },
961 .Int => |intInfo| {961 .Int => |int_info| {
962 const Uint = std.meta.Int(.unsigned, intInfo.bits);962 if (int_info.signedness == .unsigned) return x;
963 const Uint = std.meta.Int(.unsigned, int_info.bits);
963 if (x < 0) {964 if (x < 0) {
964 return ~@bitCast(Uint, x +% -1);965 return ~@bitCast(Uint, x +% -1);
965 } else {966 } else {
src/Sema.zig+76-11
...@@ -3351,9 +3351,10 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v...@@ -3351,9 +3351,10 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
3351 // Check for the possibility of this pattern:3351 // Check for the possibility of this pattern:
3352 // %a = ret_ptr3352 // %a = ret_ptr
3353 // %b = store(%a, %c)3353 // %b = store(%a, %c)
3354 // Where %c is an error union. In such case we need to add to the current function's3354 // Where %c is an error union or error set. In such case we need to add
3355 // inferred error set, if any.3355 // to the current function's inferred error set, if any.
3356 if (sema.typeOf(operand).zigTypeTag() == .ErrorUnion and3356 if ((sema.typeOf(operand).zigTypeTag() == .ErrorUnion or
3357 sema.typeOf(operand).zigTypeTag() == .ErrorSet) and
3357 sema.fn_ret_ty.zigTypeTag() == .ErrorUnion)3358 sema.fn_ret_ty.zigTypeTag() == .ErrorUnion)
3358 {3359 {
3359 if (Zir.refToIndex(extra.lhs)) |ptr_index| {3360 if (Zir.refToIndex(extra.lhs)) |ptr_index| {
...@@ -7665,6 +7666,8 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -7665,6 +7666,8 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
7665 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);7666 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);
7666 const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs);7667 const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs);
76677668
7669 // tuples are structs but they don't have a namespace
7670 if (container_type.isTuple()) return Air.Inst.Ref.bool_false;
7668 const namespace = container_type.getNamespace() orelse return sema.fail(7671 const namespace = container_type.getNamespace() orelse return sema.fail(
7669 block,7672 block,
7670 lhs_src,7673 lhs_src,
...@@ -9886,7 +9889,65 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -9886,7 +9889,65 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
9886 }),9889 }),
9887 ),9890 ),
9888 .Fn => {9891 .Fn => {
9892 // TODO: look into memoizing this result.
9889 const info = ty.fnInfo();9893 const info = ty.fnInfo();
9894 var params_anon_decl = try block.startAnonDecl(src);
9895 defer params_anon_decl.deinit();
9896
9897 const param_vals = try params_anon_decl.arena().alloc(Value, info.param_types.len);
9898 for (param_vals) |*param_val, i| {
9899 const param_ty = info.param_types[i];
9900 const is_generic = param_ty.tag() == .generic_poison;
9901 const param_ty_val = if (is_generic)
9902 Value.@"null"
9903 else
9904 try Value.Tag.opt_payload.create(
9905 params_anon_decl.arena(),
9906 try Value.Tag.ty.create(params_anon_decl.arena(), param_ty),
9907 );
9908
9909 const param_fields = try params_anon_decl.arena().create([3]Value);
9910 param_fields.* = .{
9911 // is_generic: bool,
9912 Value.makeBool(is_generic),
9913 // is_noalias: bool,
9914 Value.@"false", // TODO
9915 // arg_type: ?type,
9916 param_ty_val,
9917 };
9918 param_val.* = try Value.Tag.@"struct".create(params_anon_decl.arena(), param_fields);
9919 }
9920
9921 const args_val = v: {
9922 const fn_info_decl = (try sema.namespaceLookup(
9923 block,
9924 src,
9925 type_info_ty.getNamespace().?,
9926 "Fn",
9927 )).?;
9928 try sema.mod.declareDeclDependency(sema.owner_decl, fn_info_decl);
9929 try sema.ensureDeclAnalyzed(fn_info_decl);
9930 const param_info_decl = (try sema.namespaceLookup(
9931 block,
9932 src,
9933 fn_info_decl.val.castTag(.ty).?.data.getNamespace().?,
9934 "Param",
9935 )).?;
9936 try sema.mod.declareDeclDependency(sema.owner_decl, param_info_decl);
9937 try sema.ensureDeclAnalyzed(param_info_decl);
9938 const new_decl = try params_anon_decl.finish(
9939 try Type.Tag.array.create(params_anon_decl.arena(), .{
9940 .len = param_vals.len,
9941 .elem_type = param_info_decl.ty,
9942 }),
9943 try Value.Tag.array.create(
9944 params_anon_decl.arena(),
9945 param_vals,
9946 ),
9947 );
9948 break :v try Value.Tag.decl_ref.create(sema.arena, new_decl);
9949 };
9950
9890 const field_values = try sema.arena.alloc(Value, 6);9951 const field_values = try sema.arena.alloc(Value, 6);
9891 // calling_convention: CallingConvention,9952 // calling_convention: CallingConvention,
9892 field_values[0] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.cc));9953 field_values[0] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.cc));
...@@ -9897,9 +9958,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -9897,9 +9958,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
9897 // is_var_args: bool,9958 // is_var_args: bool,
9898 field_values[3] = Value.makeBool(info.is_var_args);9959 field_values[3] = Value.makeBool(info.is_var_args);
9899 // return_type: ?type,9960 // return_type: ?type,
9900 field_values[4] = try Value.Tag.ty.create(sema.arena, ty.fnReturnType());9961 field_values[4] = try Value.Tag.ty.create(sema.arena, info.return_type);
9901 // args: []const FnArg,9962 // args: []const Fn.Param,
9902 field_values[5] = Value.@"null"; // TODO9963 field_values[5] = args_val;
99039964
9904 return sema.addConstant(9965 return sema.addConstant(
9905 type_info_ty,9966 type_info_ty,
...@@ -10102,7 +10163,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -10102,7 +10163,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
10102 }),10163 }),
10103 try Value.Tag.array.create(10164 try Value.Tag.array.create(
10104 fields_anon_decl.arena(),10165 fields_anon_decl.arena(),
10105 try fields_anon_decl.arena().dupe(Value, enum_field_vals),10166 enum_field_vals,
10106 ),10167 ),
10107 );10168 );
10108 break :v try Value.Tag.decl_ref.create(sema.arena, new_decl);10169 break :v try Value.Tag.decl_ref.create(sema.arena, new_decl);
...@@ -12128,7 +12189,7 @@ fn checkPtrOperand(...@@ -12128,7 +12189,7 @@ fn checkPtrOperand(
12128 ty: Type,12189 ty: Type,
12129) CompileError!void {12190) CompileError!void {
12130 switch (ty.zigTypeTag()) {12191 switch (ty.zigTypeTag()) {
12131 .Pointer => {},12192 .Pointer => return,
12132 .Fn => {12193 .Fn => {
12133 const msg = msg: {12194 const msg = msg: {
12134 const msg = try sema.errMsg(12195 const msg = try sema.errMsg(
...@@ -12145,8 +12206,10 @@ fn checkPtrOperand(...@@ -12145,8 +12206,10 @@ fn checkPtrOperand(
12145 };12206 };
12146 return sema.failWithOwnedErrorMsg(msg);12207 return sema.failWithOwnedErrorMsg(msg);
12147 },12208 },
12148 else => return sema.fail(block, ty_src, "expected pointer, found '{}'", .{ty}),12209 .Optional => if (ty.isPtrLikeOptional()) return,
12210 else => {},
12149 }12211 }
12212 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty});
12150}12213}
1215112214
12152fn checkPtrType(12215fn checkPtrType(
...@@ -12156,7 +12219,7 @@ fn checkPtrType(...@@ -12156,7 +12219,7 @@ fn checkPtrType(
12156 ty: Type,12219 ty: Type,
12157) CompileError!void {12220) CompileError!void {
12158 switch (ty.zigTypeTag()) {12221 switch (ty.zigTypeTag()) {
12159 .Pointer => {},12222 .Pointer => return,
12160 .Fn => {12223 .Fn => {
12161 const msg = msg: {12224 const msg = msg: {
12162 const msg = try sema.errMsg(12225 const msg = try sema.errMsg(
...@@ -12173,8 +12236,10 @@ fn checkPtrType(...@@ -12173,8 +12236,10 @@ fn checkPtrType(
12173 };12236 };
12174 return sema.failWithOwnedErrorMsg(msg);12237 return sema.failWithOwnedErrorMsg(msg);
12175 },12238 },
12176 else => return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty}),12239 .Optional => if (ty.isPtrLikeOptional()) return,
12240 else => {},
12177 }12241 }
12242 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty});
12178}12243}
1217912244
12180fn checkVectorElemType(12245fn checkVectorElemType(
src/stage1/ir.cpp+4-5
...@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour...@@ -18750,8 +18750,8 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
18750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;18750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
18751 fields[4]->data.x_optional = return_type;18751 fields[4]->data.x_optional = return_type;
18752 }18752 }
18753 // args: []TypeInfo.FnArg18753 // args: []TypeInfo.Fn.Param
18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);18754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
18755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {18755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
18756 zig_unreachable();18756 zig_unreachable();
18757 }18757 }
...@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_...@@ -19614,14 +19614,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
19614 assert(args_arr->data.x_array.special == ConstArraySpecialNone);19614 assert(args_arr->data.x_array.special == ConstArraySpecialNone);
19615 for (size_t i = 0; i < args_len; i++) {19615 for (size_t i = 0; i < args_len; i++) {
19616 ZigValue *arg_value = &args_arr->data.x_array.data.s_none.elements[i];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 FnTypeParamInfo *info = &fn_type_id.param_info[i];19617 FnTypeParamInfo *info = &fn_type_id.param_info[i];
19619 Error err;19618 Error err;
19620 bool is_generic;19619 bool is_generic;
19621 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))19620 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
19622 return ira->codegen->invalid_inst_gen->value->type;19621 return ira->codegen->invalid_inst_gen->value->type;
19623 if (is_generic) {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 return ira->codegen->invalid_inst_gen->value->type;19624 return ira->codegen->invalid_inst_gen->value->type;
19626 }19625 }
19627 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))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,7 +19628,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
19629 ZigType *type = get_const_field_meta_type_optional(19628 ZigType *type = get_const_field_meta_type_optional(
19630 ira, source_node, arg_value, "arg_type", 2);19629 ira, source_node, arg_value, "arg_type", 2);
19631 if (type == nullptr) {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 return ira->codegen->invalid_inst_gen->value->type;19632 return ira->codegen->invalid_inst_gen->value->type;
19634 }19633 }
19635 info->type = type;19634 info->type = type;
src/type.zig+4-2
...@@ -593,10 +593,12 @@ pub const Type = extern union {...@@ -593,10 +593,12 @@ pub const Type = extern union {
593593
594 for (a_info.param_types) |a_param_ty, i| {594 for (a_info.param_types) |a_param_ty, i| {
595 const b_param_ty = b_info.param_types[i];595 const b_param_ty = b_info.param_types[i];
596 if (!eql(a_param_ty, b_param_ty))596 if (a_info.comptime_params[i] != b_info.comptime_params[i])
597 return false;597 return false;
598598
599 if (a_info.comptime_params[i] != b_info.comptime_params[i])599 if (a_param_ty.tag() == .generic_poison) continue;
600 if (b_param_ty.tag() == .generic_poison) continue;
601 if (!eql(a_param_ty, b_param_ty))
600 return false;602 return false;
601 }603 }
602604
test/behavior.zig+9-9
...@@ -120,6 +120,15 @@ test {...@@ -120,6 +120,15 @@ test {
120 _ = @import("behavior/sizeof_and_typeof.zig");120 _ = @import("behavior/sizeof_and_typeof.zig");
121 _ = @import("behavior/switch.zig");121 _ = @import("behavior/switch.zig");
122 _ = @import("behavior/widening.zig");122 _ = @import("behavior/widening.zig");
123 _ = @import("behavior/bugs/421.zig");
124 _ = @import("behavior/bugs/726.zig");
125 _ = @import("behavior/bugs/1421.zig");
126 _ = @import("behavior/bugs/2114.zig");
127 _ = @import("behavior/bugs/3742.zig");
128 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
129 _ = @import("behavior/switch_prong_err_enum.zig");
130 _ = @import("behavior/switch_prong_implicit_cast.zig");
131 _ = @import("behavior/union_with_members.zig");
123132
124 if (builtin.zig_backend == .stage1) {133 if (builtin.zig_backend == .stage1) {
125 // Tests that only pass for the stage1 backend.134 // Tests that only pass for the stage1 backend.
...@@ -128,20 +137,15 @@ test {...@@ -128,20 +137,15 @@ test {
128 _ = @import("behavior/async_fn.zig");137 _ = @import("behavior/async_fn.zig");
129 }138 }
130 _ = @import("behavior/await_struct.zig");139 _ = @import("behavior/await_struct.zig");
131 _ = @import("behavior/bugs/421.zig");
132 _ = @import("behavior/bugs/529.zig");140 _ = @import("behavior/bugs/529.zig");
133 _ = @import("behavior/bugs/718.zig");141 _ = @import("behavior/bugs/718.zig");
134 _ = @import("behavior/bugs/726.zig");
135 _ = @import("behavior/bugs/828.zig");142 _ = @import("behavior/bugs/828.zig");
136 _ = @import("behavior/bugs/920.zig");143 _ = @import("behavior/bugs/920.zig");
137 _ = @import("behavior/bugs/1120.zig");144 _ = @import("behavior/bugs/1120.zig");
138 _ = @import("behavior/bugs/1421.zig");
139 _ = @import("behavior/bugs/1442.zig");145 _ = @import("behavior/bugs/1442.zig");
140 _ = @import("behavior/bugs/1607.zig");146 _ = @import("behavior/bugs/1607.zig");
141 _ = @import("behavior/bugs/1851.zig");147 _ = @import("behavior/bugs/1851.zig");
142 _ = @import("behavior/bugs/2114.zig");
143 _ = @import("behavior/bugs/3384.zig");148 _ = @import("behavior/bugs/3384.zig");
144 _ = @import("behavior/bugs/3742.zig");
145 _ = @import("behavior/bugs/3779.zig");149 _ = @import("behavior/bugs/3779.zig");
146 _ = @import("behavior/bugs/4328.zig");150 _ = @import("behavior/bugs/4328.zig");
147 _ = @import("behavior/bugs/5398.zig");151 _ = @import("behavior/bugs/5398.zig");
...@@ -161,12 +165,8 @@ test {...@@ -161,12 +165,8 @@ test {
161 _ = @import("behavior/muladd.zig");165 _ = @import("behavior/muladd.zig");
162 _ = @import("behavior/select.zig");166 _ = @import("behavior/select.zig");
163 _ = @import("behavior/shuffle.zig");167 _ = @import("behavior/shuffle.zig");
164 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
165 _ = @import("behavior/struct_contains_slice_of_itself.zig");168 _ = @import("behavior/struct_contains_slice_of_itself.zig");
166 _ = @import("behavior/switch_prong_err_enum.zig");
167 _ = @import("behavior/switch_prong_implicit_cast.zig");
168 _ = @import("behavior/typename.zig");169 _ = @import("behavior/typename.zig");
169 _ = @import("behavior/union_with_members.zig");
170 _ = @import("behavior/vector.zig");170 _ = @import("behavior/vector.zig");
171 if (builtin.target.cpu.arch == .wasm32) {171 if (builtin.target.cpu.arch == .wasm32) {
172 _ = @import("behavior/wasm.zig");172 _ = @import("behavior/wasm.zig");
test/behavior/src.zig+12-13
...@@ -1,21 +1,20 @@...@@ -1,21 +1,20 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const expect = std.testing.expect;
4
5test "@src" {
6 // TODO why is this failing on stage1?
7 return error.SkipZigTest;
8
9 // try doTheTest();
10}
11
12fn doTheTest() !void {1fn doTheTest() !void {
13 const src = @src();2 const src = @src(); // do not move
143
15 try expect(src.line == 9);4 try expect(src.line == 2);
16 try expect(src.column == 17);5 try expect(src.column == 17);
17 try expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));6 try expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));
18 try expect(std.mem.endsWith(u8, src.file, "src.zig"));7 try expect(std.mem.endsWith(u8, src.file, "src.zig"));
19 try expect(src.fn_name[src.fn_name.len] == 0);8 try expect(src.fn_name[src.fn_name.len] == 0);
20 try expect(src.file[src.file.len] == 0);9 try expect(src.file[src.file.len] == 0);
21}10}
11
12const std = @import("std");
13const builtin = @import("builtin");
14const expect = std.testing.expect;
15
16test "@src" {
17 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
18
19 try doTheTest();
20}
test/behavior/type_info.zig+4-1
...@@ -323,7 +323,9 @@ fn testOpaque() !void {...@@ -323,7 +323,9 @@ fn testOpaque() !void {
323}323}
324324
325test "type info: function type info" {325test "type info: function type info" {
326 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO326 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
327 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
328 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
327329
328 // wasm doesn't support align attributes on functions330 // wasm doesn't support align attributes on functions
329 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;331 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;
...@@ -343,6 +345,7 @@ fn testFunction() !void {...@@ -343,6 +345,7 @@ fn testFunction() !void {
343 const fn_aligned_info = @typeInfo(@TypeOf(fooAligned));345 const fn_aligned_info = @typeInfo(@TypeOf(fooAligned));
344 try expect(fn_aligned_info.Fn.alignment == 4);346 try expect(fn_aligned_info.Fn.alignment == 4);
345347
348 if (builtin.zig_backend != .stage1) return; // no bound fn in stage2
346 const test_instance: TestPackedStruct = undefined;349 const test_instance: TestPackedStruct = undefined;
347 const bound_fn_info = @typeInfo(@TypeOf(test_instance.foo));350 const bound_fn_info = @typeInfo(@TypeOf(test_instance.foo));
348 try expect(bound_fn_info == .BoundFn);351 try expect(bound_fn_info == .BoundFn);
test/compile_errors.zig+3-3
...@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -450,7 +450,7 @@ pub fn addCases(ctx: *TestContext) !void {
450 \\ .is_generic = true,450 \\ .is_generic = true,
451 \\ .is_var_args = false,451 \\ .is_var_args = false,
452 \\ .return_type = u0,452 \\ .return_type = u0,
453 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},453 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
454 \\ },454 \\ },
455 \\});455 \\});
456 \\comptime { _ = Foo; }456 \\comptime { _ = Foo; }
...@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -466,7 +466,7 @@ pub fn addCases(ctx: *TestContext) !void {
466 \\ .is_generic = false,466 \\ .is_generic = false,
467 \\ .is_var_args = true,467 \\ .is_var_args = true,
468 \\ .return_type = u0,468 \\ .return_type = u0,
469 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},469 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
470 \\ },470 \\ },
471 \\});471 \\});
472 \\comptime { _ = Foo; }472 \\comptime { _ = Foo; }
...@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -482,7 +482,7 @@ pub fn addCases(ctx: *TestContext) !void {
482 \\ .is_generic = false,482 \\ .is_generic = false,
483 \\ .is_var_args = false,483 \\ .is_var_args = false,
484 \\ .return_type = null,484 \\ .return_type = null,
485 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},485 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
486 \\ },486 \\ },
487 \\});487 \\});
488 \\comptime { _ = Foo; }488 \\comptime { _ = Foo; }