diff --git a/doc/langref.html.in b/doc/langref.html.in index 2e235aa80f..751e1f1a1f 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -5242,7 +5242,7 @@ const math = std.math; const testing = std.testing; test "fn reflection" { - try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.args[0].arg_type.? == bool); + try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.args[0].type.? == bool); try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 2d56b477f9..f62969e97d 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -374,7 +374,7 @@ pub const Type = union(enum) { pub const Param = struct { is_generic: bool, is_noalias: bool, - arg_type: ?type, + type: ?type, }; }; diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 8c65ab6fd2..6842cb9ca1 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1724,7 +1724,7 @@ pub const ParseIntError = error{ /// ) !void; /// pub fn Formatter(comptime format_fn: anytype) type { - const Data = @typeInfo(@TypeOf(format_fn)).Fn.args[0].arg_type.?; + const Data = @typeInfo(@TypeOf(format_fn)).Fn.args[0].type.?; return struct { data: Data, pub fn format( diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 7f9783f91d..ad6165b186 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -190,7 +190,7 @@ pub fn verifyContext( errors = errors ++ lazy.err_invalid_hash_signature; } else { var emitted_signature = false; - if (func.args[0].arg_type) |Self| { + if (func.args[0].type) |Self| { if (Self == Context) { // pass, this is always fine. } else if (Self == *const Context) { @@ -231,12 +231,12 @@ pub fn verifyContext( errors = errors ++ ", but is " ++ @typeName(Self); } } - if (func.args[1].arg_type != null and func.args[1].arg_type.? != PseudoKey) { + if (func.args[1].type != null and func.args[1].type.? != PseudoKey) { if (!emitted_signature) { errors = errors ++ lazy.err_invalid_hash_signature; emitted_signature = true; } - errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].arg_type.?); + errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].type.?); } if (func.return_type != null and func.return_type.? != Hash) { if (!emitted_signature) { @@ -267,7 +267,7 @@ pub fn verifyContext( errors = errors ++ lazy.err_invalid_eql_signature; } else { var emitted_signature = false; - if (func.args[0].arg_type) |Self| { + if (func.args[0].type) |Self| { if (Self == Context) { // pass, this is always fine. } else if (Self == *const Context) { @@ -308,19 +308,19 @@ pub fn verifyContext( errors = errors ++ ", but is " ++ @typeName(Self); } } - if (func.args[1].arg_type.? != PseudoKey) { + if (func.args[1].type.? != PseudoKey) { if (!emitted_signature) { errors = errors ++ lazy.err_invalid_eql_signature; emitted_signature = true; } - errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].arg_type.?); + errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].type.?); } - if (func.args[2].arg_type.? != Key) { + if (func.args[2].type.? != Key) { if (!emitted_signature) { errors = errors ++ lazy.err_invalid_eql_signature; emitted_signature = true; } - errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.args[2].arg_type.?); + errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.args[2].type.?); } if (func.return_type.? != bool) { if (!emitted_signature) { diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 71e37ad8a6..d4b9c940df 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1086,7 +1086,7 @@ pub fn ArgsTuple(comptime Function: type) type { var argument_field_list: [function_info.args.len]type = undefined; inline for (function_info.args) |arg, i| { - const T = arg.arg_type.?; + const T = arg.type.?; argument_field_list[i] = T; } diff --git a/lib/std/start.zig b/lib/std/start.zig index b8c74a6373..ac92af9c67 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -634,7 +634,7 @@ pub fn callMain() u8 { } pub fn call_wWinMain() std.os.windows.INT { - const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].arg_type.?; + const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].type.?; const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); diff --git a/src/Sema.zig b/src/Sema.zig index e67965271a..ab839f19a3 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -15316,7 +15316,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai Value.makeBool(is_generic), // is_noalias: bool, Value.makeBool(is_noalias), - // arg_type: ?type, + // type: ?type, param_ty_val, }; param_val.* = try Value.Tag.aggregate.create(params_anon_decl.arena(), param_fields); @@ -18730,7 +18730,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in const arg_is_generic = arg_val[0].toBool(); // is_noalias: bool, const arg_is_noalias = arg_val[1].toBool(); - // arg_type: ?type, + // type: ?type, const param_type_opt_val = arg_val[2]; if (arg_is_generic) { diff --git a/test/behavior/bugs/12885.zig b/test/behavior/bugs/12885.zig index 2a802efd04..0ec982353e 100644 --- a/test/behavior/bugs/12885.zig +++ b/test/behavior/bugs/12885.zig @@ -16,7 +16,7 @@ test "ErrorSet comptime_field_ptr" { const fn_info = .{ .args = [_]builtin.Type.Fn.Param{ - .{ .is_generic = false, .is_noalias = false, .arg_type = u8 }, + .{ .is_generic = false, .is_noalias = false, .type = u8 }, }, }; const Bar = @Type(.{ diff --git a/test/behavior/reflection.zig b/test/behavior/reflection.zig index c0246f1221..ff72f3b788 100644 --- a/test/behavior/reflection.zig +++ b/test/behavior/reflection.zig @@ -10,9 +10,9 @@ test "reflection: function return type, var args, and param types" { try expect(info.return_type.? == i32); try expect(!info.is_var_args); try expect(info.args.len == 3); - try expect(info.args[0].arg_type.? == bool); - try expect(info.args[1].arg_type.? == i32); - try expect(info.args[2].arg_type.? == f32); + try expect(info.args[0].type.? == bool); + try expect(info.args[1].type.? == i32); + try expect(info.args[2].type.? == f32); } } diff --git a/test/behavior/type.zig b/test/behavior/type.zig index b2db2a73b5..1eabdd4245 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -513,8 +513,8 @@ test "Type.Fn" { .is_var_args = false, .return_type = void, .args = &.{ - .{ .is_generic = false, .is_noalias = false, .arg_type = c_int }, - .{ .is_generic = false, .is_noalias = false, .arg_type = some_ptr }, + .{ .is_generic = false, .is_noalias = false, .type = c_int }, + .{ .is_generic = false, .is_noalias = false, .type = some_ptr }, }, } }; diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index 2d9eec645a..9f3c0a773f 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -379,29 +379,29 @@ test "type info: generic function types" { const G1 = @typeInfo(@TypeOf(generic1)); try expect(G1.Fn.args.len == 1); try expect(G1.Fn.args[0].is_generic == true); - try expect(G1.Fn.args[0].arg_type == null); + try expect(G1.Fn.args[0].type == null); try expect(G1.Fn.return_type == void); const G2 = @typeInfo(@TypeOf(generic2)); try expect(G2.Fn.args.len == 3); try expect(G2.Fn.args[0].is_generic == false); - try expect(G2.Fn.args[0].arg_type == type); + try expect(G2.Fn.args[0].type == type); try expect(G2.Fn.args[1].is_generic == true); - try expect(G2.Fn.args[1].arg_type == null); + try expect(G2.Fn.args[1].type == null); try expect(G2.Fn.args[2].is_generic == false); - try expect(G2.Fn.args[2].arg_type == u8); + try expect(G2.Fn.args[2].type == u8); try expect(G2.Fn.return_type == void); const G3 = @typeInfo(@TypeOf(generic3)); try expect(G3.Fn.args.len == 1); try expect(G3.Fn.args[0].is_generic == true); - try expect(G3.Fn.args[0].arg_type == null); + try expect(G3.Fn.args[0].type == null); try expect(G3.Fn.return_type == null); const G4 = @typeInfo(@TypeOf(generic4)); try expect(G4.Fn.args.len == 1); try expect(G4.Fn.args[0].is_generic == true); - try expect(G4.Fn.args[0].arg_type == null); + try expect(G4.Fn.args[0].type == null); try expect(G4.Fn.return_type == null); } diff --git a/test/cases/fn_typeinfo_passed_to_comptime_fn.zig b/test/cases/fn_typeinfo_passed_to_comptime_fn.zig index 29f1d0c67b..b31014939b 100644 --- a/test/cases/fn_typeinfo_passed_to_comptime_fn.zig +++ b/test/cases/fn_typeinfo_passed_to_comptime_fn.zig @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { return 8; } fn foo(comptime info: std.builtin.Type) !void { - try std.testing.expect(info.Fn.args[0].arg_type.? == ?*c_int); + try std.testing.expect(info.Fn.args[0].type.? == ?*c_int); } // run