| author | |
| committer | |
| log | 7350ea3e2da4d4e6ef5092cd9f0832beef0291d5 |
| tree | 071595ca763a8fe5ed39751e9f4d1cb0079a028a |
| parent | 20d3fd901eb6a7ddc1340107ae00e0f2014552e3 |
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.14 files changed, 44 insertions(+), 44 deletions(-)
doc/langref.html.in+1-1| ... | @@ -5242,7 +5242,7 @@ const math = std.math; | ... | @@ -5242,7 +5242,7 @@ const math = std.math; |
| 5242 | const testing = std.testing; | 5242 | const testing = std.testing; |
| 5243 | 5243 | ||
| 5244 | test "fn reflection" { | 5244 | test "fn reflection" { |
| 5245 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.args[0].type.? == bool); | 5245 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[0].type.? == bool); |
| 5246 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); | 5246 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); |
| 5247 | 5247 | ||
| 5248 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); | 5248 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); |
lib/std/builtin.zig+1-1| ... | @@ -367,7 +367,7 @@ pub const Type = union(enum) { | ... | @@ -367,7 +367,7 @@ pub const Type = union(enum) { |
| 367 | is_var_args: bool, | 367 | is_var_args: bool, |
| 368 | /// TODO change the language spec to make this not optional. | 368 | /// TODO change the language spec to make this not optional. |
| 369 | return_type: ?type, | 369 | return_type: ?type, |
| 370 | args: []const Param, | 370 | params: []const Param, |
| 371 | 371 | ||
| 372 | /// This data structure is used by the Zig language code generation and | 372 | /// This data structure is used by the Zig language code generation and |
| 373 | /// therefore must be kept in sync with the compiler implementation. | 373 | /// therefore must be kept in sync with the compiler implementation. |
lib/std/fmt.zig+1-1| ... | @@ -1724,7 +1724,7 @@ pub const ParseIntError = error{ | ... | @@ -1724,7 +1724,7 @@ pub const ParseIntError = error{ |
| 1724 | /// ) !void; | 1724 | /// ) !void; |
| 1725 | /// | 1725 | /// |
| 1726 | pub fn Formatter(comptime format_fn: anytype) type { | 1726 | pub fn Formatter(comptime format_fn: anytype) type { |
| 1727 | const Data = @typeInfo(@TypeOf(format_fn)).Fn.args[0].type.?; | 1727 | const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?; |
| 1728 | return struct { | 1728 | return struct { |
| 1729 | data: Data, | 1729 | data: Data, |
| 1730 | pub fn format( | 1730 | pub fn format( |
lib/std/hash_map.zig+10-10| ... | @@ -186,11 +186,11 @@ pub fn verifyContext( | ... | @@ -186,11 +186,11 @@ pub fn verifyContext( |
| 186 | const info = @typeInfo(@TypeOf(hash)); | 186 | const info = @typeInfo(@TypeOf(hash)); |
| 187 | if (info == .Fn) { | 187 | if (info == .Fn) { |
| 188 | const func = info.Fn; | 188 | const func = info.Fn; |
| 189 | if (func.args.len != 2) { | 189 | if (func.params.len != 2) { |
| 190 | errors = errors ++ lazy.err_invalid_hash_signature; | 190 | errors = errors ++ lazy.err_invalid_hash_signature; |
| 191 | } else { | 191 | } else { |
| 192 | var emitted_signature = false; | 192 | var emitted_signature = false; |
| 193 | if (func.args[0].type) |Self| { | 193 | if (func.params[0].type) |Self| { |
| 194 | if (Self == Context) { | 194 | if (Self == Context) { |
| 195 | // pass, this is always fine. | 195 | // pass, this is always fine. |
| 196 | } else if (Self == *const Context) { | 196 | } else if (Self == *const Context) { |
| ... | @@ -231,12 +231,12 @@ pub fn verifyContext( | ... | @@ -231,12 +231,12 @@ pub fn verifyContext( |
| 231 | errors = errors ++ ", but is " ++ @typeName(Self); | 231 | errors = errors ++ ", but is " ++ @typeName(Self); |
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | if (func.args[1].type != null and func.args[1].type.? != PseudoKey) { | 234 | if (func.params[1].type != null and func.params[1].type.? != PseudoKey) { |
| 235 | if (!emitted_signature) { | 235 | if (!emitted_signature) { |
| 236 | errors = errors ++ lazy.err_invalid_hash_signature; | 236 | errors = errors ++ lazy.err_invalid_hash_signature; |
| 237 | emitted_signature = true; | 237 | emitted_signature = true; |
| 238 | } | 238 | } |
| 239 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].type.?); | 239 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); |
| 240 | } | 240 | } |
| 241 | if (func.return_type != null and func.return_type.? != Hash) { | 241 | if (func.return_type != null and func.return_type.? != Hash) { |
| 242 | if (!emitted_signature) { | 242 | if (!emitted_signature) { |
| ... | @@ -263,11 +263,11 @@ pub fn verifyContext( | ... | @@ -263,11 +263,11 @@ pub fn verifyContext( |
| 263 | if (info == .Fn) { | 263 | if (info == .Fn) { |
| 264 | const func = info.Fn; | 264 | const func = info.Fn; |
| 265 | const args_len = if (is_array) 4 else 3; | 265 | const args_len = if (is_array) 4 else 3; |
| 266 | if (func.args.len != args_len) { | 266 | if (func.params.len != args_len) { |
| 267 | errors = errors ++ lazy.err_invalid_eql_signature; | 267 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 268 | } else { | 268 | } else { |
| 269 | var emitted_signature = false; | 269 | var emitted_signature = false; |
| 270 | if (func.args[0].type) |Self| { | 270 | if (func.params[0].type) |Self| { |
| 271 | if (Self == Context) { | 271 | if (Self == Context) { |
| 272 | // pass, this is always fine. | 272 | // pass, this is always fine. |
| 273 | } else if (Self == *const Context) { | 273 | } else if (Self == *const Context) { |
| ... | @@ -308,19 +308,19 @@ pub fn verifyContext( | ... | @@ -308,19 +308,19 @@ pub fn verifyContext( |
| 308 | errors = errors ++ ", but is " ++ @typeName(Self); | 308 | errors = errors ++ ", but is " ++ @typeName(Self); |
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| 311 | if (func.args[1].type.? != PseudoKey) { | 311 | if (func.params[1].type.? != PseudoKey) { |
| 312 | if (!emitted_signature) { | 312 | if (!emitted_signature) { |
| 313 | errors = errors ++ lazy.err_invalid_eql_signature; | 313 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 314 | emitted_signature = true; | 314 | emitted_signature = true; |
| 315 | } | 315 | } |
| 316 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].type.?); | 316 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); |
| 317 | } | 317 | } |
| 318 | if (func.args[2].type.? != Key) { | 318 | if (func.params[2].type.? != Key) { |
| 319 | if (!emitted_signature) { | 319 | if (!emitted_signature) { |
| 320 | errors = errors ++ lazy.err_invalid_eql_signature; | 320 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 321 | emitted_signature = true; | 321 | emitted_signature = true; |
| 322 | } | 322 | } |
| 323 | errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.args[2].type.?); | 323 | errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.params[2].type.?); |
| 324 | } | 324 | } |
| 325 | if (func.return_type.? != bool) { | 325 | if (func.return_type.? != bool) { |
| 326 | if (!emitted_signature) { | 326 | if (!emitted_signature) { |
lib/std/meta.zig+2-2| ... | @@ -1084,8 +1084,8 @@ pub fn ArgsTuple(comptime Function: type) type { | ... | @@ -1084,8 +1084,8 @@ pub fn ArgsTuple(comptime Function: type) type { |
| 1084 | if (function_info.is_var_args) | 1084 | if (function_info.is_var_args) |
| 1085 | @compileError("Cannot create ArgsTuple for variadic function"); | 1085 | @compileError("Cannot create ArgsTuple for variadic function"); |
| 1086 | 1086 | ||
| 1087 | var argument_field_list: [function_info.args.len]type = undefined; | 1087 | var argument_field_list: [function_info.params.len]type = undefined; |
| 1088 | inline for (function_info.args) |arg, i| { | 1088 | inline for (function_info.params) |arg, i| { |
| 1089 | const T = arg.type.?; | 1089 | const T = arg.type.?; |
| 1090 | argument_field_list[i] = T; | 1090 | argument_field_list[i] = T; |
| 1091 | } | 1091 | } |
lib/std/start.zig+1-1| ... | @@ -634,7 +634,7 @@ pub fn callMain() u8 { | ... | @@ -634,7 +634,7 @@ pub fn callMain() u8 { |
| 634 | } | 634 | } |
| 635 | 635 | ||
| 636 | pub fn call_wWinMain() std.os.windows.INT { | 636 | pub fn call_wWinMain() std.os.windows.INT { |
| 637 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].type.?; | 637 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; |
| 638 | const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); | 638 | const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); |
| 639 | const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); | 639 | const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); |
| 640 | 640 |
test/behavior/bugs/12885.zig+2-2| ... | @@ -15,7 +15,7 @@ test "ErrorSet comptime_field_ptr" { | ... | @@ -15,7 +15,7 @@ test "ErrorSet comptime_field_ptr" { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | const fn_info = .{ | 17 | const fn_info = .{ |
| 18 | .args = [_]builtin.Type.Fn.Param{ | 18 | .params = [_]builtin.Type.Fn.Param{ |
| 19 | .{ .is_generic = false, .is_noalias = false, .type = u8 }, | 19 | .{ .is_generic = false, .is_noalias = false, .type = u8 }, |
| 20 | }, | 20 | }, |
| 21 | }; | 21 | }; |
| ... | @@ -26,7 +26,7 @@ const Bar = @Type(.{ | ... | @@ -26,7 +26,7 @@ const Bar = @Type(.{ |
| 26 | .is_generic = false, | 26 | .is_generic = false, |
| 27 | .is_var_args = false, | 27 | .is_var_args = false, |
| 28 | .return_type = void, | 28 | .return_type = void, |
| 29 | .args = &fn_info.args, | 29 | .params = &fn_info.params, |
| 30 | }, | 30 | }, |
| 31 | }); | 31 | }); |
| 32 | test "fn comptime_field_ptr" { | 32 | test "fn comptime_field_ptr" { |
test/behavior/reflection.zig+4-4| ... | @@ -9,10 +9,10 @@ test "reflection: function return type, var args, and param types" { | ... | @@ -9,10 +9,10 @@ test "reflection: function return type, var args, and param types" { |
| 9 | const info = @typeInfo(@TypeOf(dummy)).Fn; | 9 | const info = @typeInfo(@TypeOf(dummy)).Fn; |
| 10 | try expect(info.return_type.? == i32); | 10 | try expect(info.return_type.? == i32); |
| 11 | try expect(!info.is_var_args); | 11 | try expect(!info.is_var_args); |
| 12 | try expect(info.args.len == 3); | 12 | try expect(info.params.len == 3); |
| 13 | try expect(info.args[0].type.? == bool); | 13 | try expect(info.params[0].type.? == bool); |
| 14 | try expect(info.args[1].type.? == i32); | 14 | try expect(info.params[1].type.? == i32); |
| 15 | try expect(info.args[2].type.? == f32); | 15 | try expect(info.params[2].type.? == f32); |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 |
test/behavior/type.zig+1-1| ... | @@ -512,7 +512,7 @@ test "Type.Fn" { | ... | @@ -512,7 +512,7 @@ test "Type.Fn" { |
| 512 | .is_generic = false, | 512 | .is_generic = false, |
| 513 | .is_var_args = false, | 513 | .is_var_args = false, |
| 514 | .return_type = void, | 514 | .return_type = void, |
| 515 | .args = &.{ | 515 | .params = &.{ |
| 516 | .{ .is_generic = false, .is_noalias = false, .type = c_int }, | 516 | .{ .is_generic = false, .is_noalias = false, .type = c_int }, |
| 517 | .{ .is_generic = false, .is_noalias = false, .type = some_ptr }, | 517 | .{ .is_generic = false, .is_noalias = false, .type = some_ptr }, |
| 518 | }, | 518 | }, |
test/behavior/type_info.zig+17-17| ... | @@ -365,7 +365,7 @@ fn testFunction() !void { | ... | @@ -365,7 +365,7 @@ fn testFunction() !void { |
| 365 | try expect(fn_info.Fn.alignment > 0); | 365 | try expect(fn_info.Fn.alignment > 0); |
| 366 | try expect(fn_info.Fn.calling_convention == .C); | 366 | try expect(fn_info.Fn.calling_convention == .C); |
| 367 | try expect(!fn_info.Fn.is_generic); | 367 | try expect(!fn_info.Fn.is_generic); |
| 368 | try expect(fn_info.Fn.args.len == 2); | 368 | try expect(fn_info.Fn.params.len == 2); |
| 369 | try expect(fn_info.Fn.is_var_args); | 369 | try expect(fn_info.Fn.is_var_args); |
| 370 | try expect(fn_info.Fn.return_type.? == usize); | 370 | try expect(fn_info.Fn.return_type.? == usize); |
| 371 | const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned)); | 371 | const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned)); |
| ... | @@ -377,31 +377,31 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize | ... | @@ -377,31 +377,31 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize |
| 377 | 377 | ||
| 378 | test "type info: generic function types" { | 378 | test "type info: generic function types" { |
| 379 | const G1 = @typeInfo(@TypeOf(generic1)); | 379 | const G1 = @typeInfo(@TypeOf(generic1)); |
| 380 | try expect(G1.Fn.args.len == 1); | 380 | try expect(G1.Fn.params.len == 1); |
| 381 | try expect(G1.Fn.args[0].is_generic == true); | 381 | try expect(G1.Fn.params[0].is_generic == true); |
| 382 | try expect(G1.Fn.args[0].type == null); | 382 | try expect(G1.Fn.params[0].type == null); |
| 383 | try expect(G1.Fn.return_type == void); | 383 | try expect(G1.Fn.return_type == void); |
| 384 | 384 | ||
| 385 | const G2 = @typeInfo(@TypeOf(generic2)); | 385 | const G2 = @typeInfo(@TypeOf(generic2)); |
| 386 | try expect(G2.Fn.args.len == 3); | 386 | try expect(G2.Fn.params.len == 3); |
| 387 | try expect(G2.Fn.args[0].is_generic == false); | 387 | try expect(G2.Fn.params[0].is_generic == false); |
| 388 | try expect(G2.Fn.args[0].type == type); | 388 | try expect(G2.Fn.params[0].type == type); |
| 389 | try expect(G2.Fn.args[1].is_generic == true); | 389 | try expect(G2.Fn.params[1].is_generic == true); |
| 390 | try expect(G2.Fn.args[1].type == null); | 390 | try expect(G2.Fn.params[1].type == null); |
| 391 | try expect(G2.Fn.args[2].is_generic == false); | 391 | try expect(G2.Fn.params[2].is_generic == false); |
| 392 | try expect(G2.Fn.args[2].type == u8); | 392 | try expect(G2.Fn.params[2].type == u8); |
| 393 | try expect(G2.Fn.return_type == void); | 393 | try expect(G2.Fn.return_type == void); |
| 394 | 394 | ||
| 395 | const G3 = @typeInfo(@TypeOf(generic3)); | 395 | const G3 = @typeInfo(@TypeOf(generic3)); |
| 396 | try expect(G3.Fn.args.len == 1); | 396 | try expect(G3.Fn.params.len == 1); |
| 397 | try expect(G3.Fn.args[0].is_generic == true); | 397 | try expect(G3.Fn.params[0].is_generic == true); |
| 398 | try expect(G3.Fn.args[0].type == null); | 398 | try expect(G3.Fn.params[0].type == null); |
| 399 | try expect(G3.Fn.return_type == null); | 399 | try expect(G3.Fn.return_type == null); |
| 400 | 400 | ||
| 401 | const G4 = @typeInfo(@TypeOf(generic4)); | 401 | const G4 = @typeInfo(@TypeOf(generic4)); |
| 402 | try expect(G4.Fn.args.len == 1); | 402 | try expect(G4.Fn.params.len == 1); |
| 403 | try expect(G4.Fn.args[0].is_generic == true); | 403 | try expect(G4.Fn.params[0].is_generic == true); |
| 404 | try expect(G4.Fn.args[0].type == null); | 404 | try expect(G4.Fn.params[0].type == null); |
| 405 | try expect(G4.Fn.return_type == null); | 405 | try expect(G4.Fn.return_type == null); |
| 406 | } | 406 | } |
| 407 | 407 |
test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = true, | 5 | .is_generic = true, |
| 6 | .is_var_args = false, | 6 | .is_var_args = false, |
| 7 | .return_type = u0, | 7 | .return_type = u0, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = false, | 5 | .is_generic = false, |
| 6 | .is_var_args = true, | 6 | .is_var_args = true, |
| 7 | .return_type = u0, | 7 | .return_type = u0, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = false, | 5 | .is_generic = false, |
| 6 | .is_var_args = false, | 6 | .is_var_args = false, |
| 7 | .return_type = null, | 7 | .return_type = null, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/fn_typeinfo_passed_to_comptime_fn.zig+1-1| ... | @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { | ... | @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { |
| 9 | return 8; | 9 | return 8; |
| 10 | } | 10 | } |
| 11 | fn foo(comptime info: std.builtin.Type) !void { | 11 | fn foo(comptime info: std.builtin.Type) !void { |
| 12 | try std.testing.expect(info.Fn.args[0].type.? == ?*c_int); | 12 | try std.testing.expect(info.Fn.params[0].type.? == ?*c_int); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | // run | 15 | // run |