diff --git a/doc/langref.html.in b/doc/langref.html.in index 751e1f1a1f..f93505fbfe 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].type.? == bool); + try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[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 f62969e97d..a32f8253d4 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -367,7 +367,7 @@ pub const Type = union(enum) { is_var_args: bool, /// TODO change the language spec to make this not optional. return_type: ?type, - args: []const Param, + params: []const Param, /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 6842cb9ca1..57771d8e51 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].type.?; + const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?; return struct { data: Data, pub fn format( diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index ad6165b186..05205e6f07 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -186,11 +186,11 @@ pub fn verifyContext( const info = @typeInfo(@TypeOf(hash)); if (info == .Fn) { const func = info.Fn; - if (func.args.len != 2) { + if (func.params.len != 2) { errors = errors ++ lazy.err_invalid_hash_signature; } else { var emitted_signature = false; - if (func.args[0].type) |Self| { + if (func.params[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].type != null and func.args[1].type.? != PseudoKey) { + if (func.params[1].type != null and func.params[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].type.?); + errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); } if (func.return_type != null and func.return_type.? != Hash) { if (!emitted_signature) { @@ -263,11 +263,11 @@ pub fn verifyContext( if (info == .Fn) { const func = info.Fn; const args_len = if (is_array) 4 else 3; - if (func.args.len != args_len) { + if (func.params.len != args_len) { errors = errors ++ lazy.err_invalid_eql_signature; } else { var emitted_signature = false; - if (func.args[0].type) |Self| { + if (func.params[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].type.? != PseudoKey) { + if (func.params[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].type.?); + errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); } - if (func.args[2].type.? != Key) { + if (func.params[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].type.?); + errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.params[2].type.?); } if (func.return_type.? != bool) { if (!emitted_signature) { diff --git a/lib/std/meta.zig b/lib/std/meta.zig index d4b9c940df..c2e4267998 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1084,8 +1084,8 @@ pub fn ArgsTuple(comptime Function: type) type { if (function_info.is_var_args) @compileError("Cannot create ArgsTuple for variadic function"); - var argument_field_list: [function_info.args.len]type = undefined; - inline for (function_info.args) |arg, i| { + var argument_field_list: [function_info.params.len]type = undefined; + inline for (function_info.params) |arg, i| { const T = arg.type.?; argument_field_list[i] = T; } diff --git a/lib/std/start.zig b/lib/std/start.zig index ac92af9c67..dcc0b7427a 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].type.?; + const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); diff --git a/test/behavior/bugs/12885.zig b/test/behavior/bugs/12885.zig index 0ec982353e..517def14a1 100644 --- a/test/behavior/bugs/12885.zig +++ b/test/behavior/bugs/12885.zig @@ -15,7 +15,7 @@ test "ErrorSet comptime_field_ptr" { } const fn_info = .{ - .args = [_]builtin.Type.Fn.Param{ + .params = [_]builtin.Type.Fn.Param{ .{ .is_generic = false, .is_noalias = false, .type = u8 }, }, }; @@ -26,7 +26,7 @@ const Bar = @Type(.{ .is_generic = false, .is_var_args = false, .return_type = void, - .args = &fn_info.args, + .params = &fn_info.params, }, }); test "fn comptime_field_ptr" { diff --git a/test/behavior/reflection.zig b/test/behavior/reflection.zig index ff72f3b788..4c3f8ccad5 100644 --- a/test/behavior/reflection.zig +++ b/test/behavior/reflection.zig @@ -9,10 +9,10 @@ test "reflection: function return type, var args, and param types" { const info = @typeInfo(@TypeOf(dummy)).Fn; try expect(info.return_type.? == i32); try expect(!info.is_var_args); - try expect(info.args.len == 3); - try expect(info.args[0].type.? == bool); - try expect(info.args[1].type.? == i32); - try expect(info.args[2].type.? == f32); + try expect(info.params.len == 3); + try expect(info.params[0].type.? == bool); + try expect(info.params[1].type.? == i32); + try expect(info.params[2].type.? == f32); } } diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 1eabdd4245..66ad7f55fd 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -512,7 +512,7 @@ test "Type.Fn" { .is_generic = false, .is_var_args = false, .return_type = void, - .args = &.{ + .params = &.{ .{ .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 9f3c0a773f..fa9f21f6eb 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -365,7 +365,7 @@ fn testFunction() !void { try expect(fn_info.Fn.alignment > 0); try expect(fn_info.Fn.calling_convention == .C); try expect(!fn_info.Fn.is_generic); - try expect(fn_info.Fn.args.len == 2); + try expect(fn_info.Fn.params.len == 2); try expect(fn_info.Fn.is_var_args); try expect(fn_info.Fn.return_type.? == usize); const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned)); @@ -377,31 +377,31 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize 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].type == null); + try expect(G1.Fn.params.len == 1); + try expect(G1.Fn.params[0].is_generic == true); + try expect(G1.Fn.params[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].type == type); - try expect(G2.Fn.args[1].is_generic == true); - try expect(G2.Fn.args[1].type == null); - try expect(G2.Fn.args[2].is_generic == false); - try expect(G2.Fn.args[2].type == u8); + try expect(G2.Fn.params.len == 3); + try expect(G2.Fn.params[0].is_generic == false); + try expect(G2.Fn.params[0].type == type); + try expect(G2.Fn.params[1].is_generic == true); + try expect(G2.Fn.params[1].type == null); + try expect(G2.Fn.params[2].is_generic == false); + try expect(G2.Fn.params[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].type == null); + try expect(G3.Fn.params.len == 1); + try expect(G3.Fn.params[0].is_generic == true); + try expect(G3.Fn.params[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].type == null); + try expect(G4.Fn.params.len == 1); + try expect(G4.Fn.params[0].is_generic == true); + try expect(G4.Fn.params[0].type == null); try expect(G4.Fn.return_type == null); } diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig index cf80c9f4ba..abdccdf36d 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig @@ -5,7 +5,7 @@ const Foo = @Type(.{ .is_generic = true, .is_var_args = false, .return_type = u0, - .args = &.{}, + .params = &.{}, }, }); comptime { _ = Foo; } diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig index 8328ee9b97..f3542d583a 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig @@ -5,7 +5,7 @@ const Foo = @Type(.{ .is_generic = false, .is_var_args = true, .return_type = u0, - .args = &.{}, + .params = &.{}, }, }); comptime { _ = Foo; } diff --git a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig index f6587dcd7e..49335ab693 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig @@ -5,7 +5,7 @@ const Foo = @Type(.{ .is_generic = false, .is_var_args = false, .return_type = null, - .args = &.{}, + .params = &.{}, }, }); comptime { _ = Foo; } diff --git a/test/cases/fn_typeinfo_passed_to_comptime_fn.zig b/test/cases/fn_typeinfo_passed_to_comptime_fn.zig index b31014939b..31673e5b81 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].type.? == ?*c_int); + try std.testing.expect(info.Fn.params[0].type.? == ?*c_int); } // run