std.builtin: rename Type.Fn's args to params

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.
This commit is contained in:
r00ster91
2022-12-13 21:54:04 +01:00
parent 20d3fd901e
commit 7350ea3e2d
14 changed files with 44 additions and 44 deletions

View File

@@ -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.

View File

@@ -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(

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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();