Use int type name consistently (#10579)

# Description
When referring to the type use `int` consistently. Only when referring
to the concept of integer numbers use `integer`.

- Fix `random integer` to `random int` tests
  - Forgot in #10520
- Use int instead of integer in error messages
- Use int type name in bits commands
- Fix messages in `for` examples
- Use int typename in `into` commands
- Use int typename in rest of commands
- Report errors in `nu-protocol` with int typename

Work for #10332 

# User-Facing Changes
User errorrs should now use `int` so you can easily find the necessary
commands or type annotations.

# Tests + Formatting
Only two tests found that needed updating
This commit is contained in:
Stefan Holderbach
2023-10-03 18:24:32 +02:00
committed by GitHub
parent 2cc4191ec9
commit 7c1487e18d
36 changed files with 77 additions and 93 deletions

View File

@ -22,16 +22,12 @@ impl Command for BitsAnd {
Type::List(Box::new(Type::Int)),
),
])
.required(
"target",
SyntaxShape::Int,
"target integer to perform bit and",
)
.required("target", SyntaxShape::Int, "target int to perform bit and")
.category(Category::Bits)
}
fn usage(&self) -> &str {
"Performs bitwise and for integers."
"Performs bitwise and for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -85,7 +81,7 @@ fn operate(value: Value, target: i64, head: Span) -> Value {
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -219,7 +219,7 @@ pub fn action(input: &Value, _args: &Arguments, span: Span) -> Value {
Value::Error { .. } => input.clone(),
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer, filesize, string, date, duration, binary or bool".into(),
exp_input_type: "int, filesize, string, date, duration, binary, or bool".into(),
wrong_type: other.get_type().to_string(),
dst_span: span,
src_span: other.span(),

View File

@ -158,7 +158,7 @@ fn operate(value: Value, head: Span, signed: bool, number_size: NumberBytes) ->
Value::Error { .. } => other,
_ => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -22,16 +22,12 @@ impl Command for BitsOr {
Type::List(Box::new(Type::Int)),
),
])
.required(
"target",
SyntaxShape::Int,
"target integer to perform bit or",
)
.required("target", SyntaxShape::Int, "target int to perform bit or")
.category(Category::Bits)
}
fn usage(&self) -> &str {
"Performs bitwise or for integers."
"Performs bitwise or for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -85,7 +81,7 @@ fn operate(value: Value, target: i64, head: Span) -> Value {
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -41,7 +41,7 @@ impl Command for BitsRol {
}
fn usage(&self) -> &str {
"Bitwise rotate left for integers."
"Bitwise rotate left for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -145,7 +145,7 @@ fn operate(value: Value, bits: usize, head: Span, signed: bool, number_size: Num
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -41,7 +41,7 @@ impl Command for BitsRor {
}
fn usage(&self) -> &str {
"Bitwise rotate right for integers."
"Bitwise rotate right for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -149,7 +149,7 @@ fn operate(value: Value, bits: usize, head: Span, signed: bool, number_size: Num
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -41,7 +41,7 @@ impl Command for BitsShl {
}
fn usage(&self) -> &str {
"Bitwise shift left for integers."
"Bitwise shift left for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -169,7 +169,7 @@ fn operate(value: Value, bits: usize, head: Span, signed: bool, number_size: Num
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -41,7 +41,7 @@ impl Command for BitsShr {
}
fn usage(&self) -> &str {
"Bitwise shift right for integers."
"Bitwise shift right for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -159,7 +159,7 @@ fn operate(value: Value, bits: usize, head: Span, signed: bool, number_size: Num
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -22,16 +22,12 @@ impl Command for BitsXor {
Type::List(Box::new(Type::Int)),
),
])
.required(
"target",
SyntaxShape::Int,
"target integer to perform bit xor",
)
.required("target", SyntaxShape::Int, "target int to perform bit xor")
.category(Category::Bits)
}
fn usage(&self) -> &str {
"Performs bitwise xor for integers."
"Performs bitwise xor for ints."
}
fn search_terms(&self) -> Vec<&str> {
@ -84,7 +80,7 @@ fn operate(value: Value, target: i64, head: Span) -> Value {
Value::Error { .. } => value,
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "integer".into(),
exp_input_type: "int".into(),
wrong_type: other.get_type().to_string(),
dst_span: head,
src_span: other.span(),

View File

@ -88,7 +88,7 @@ fn action(input: &Value, _args: &CellPathOnlyArgs, span: Span) -> Value {
Value::Error { .. } => input.clone(),
other => Value::error(
ShellError::OnlySupportsThisInputType {
exp_input_type: "float , integer or filesize".into(),
exp_input_type: "float, int, or filesize".into(),
wrong_type: other.get_type().to_string(),
dst_span: span,
src_span: other.span(),