forked from extern/nushell
fix small bug converting string to int (#6031)
This commit is contained in:
parent
8b6232ac87
commit
c2f8f4bd9b
@ -291,7 +291,7 @@ fn int_from_string(a_string: &str, span: Span) -> Result<i64, ShellError> {
|
|||||||
};
|
};
|
||||||
Ok(num)
|
Ok(num)
|
||||||
}
|
}
|
||||||
_ => match a_string.parse::<i64>() {
|
_ => match trimmed.parse::<i64>() {
|
||||||
Ok(n) => Ok(n),
|
Ok(n) => Ok(n),
|
||||||
Err(_) => match a_string.parse::<f64>() {
|
Err(_) => match a_string.parse::<f64>() {
|
||||||
Ok(f) => Ok(f as i64),
|
Ok(f) => Ok(f as i64),
|
||||||
@ -299,7 +299,10 @@ fn int_from_string(a_string: &str, span: Span) -> Result<i64, ShellError> {
|
|||||||
"int".to_string(),
|
"int".to_string(),
|
||||||
"string".to_string(),
|
"string".to_string(),
|
||||||
span,
|
span,
|
||||||
None,
|
Some(format!(
|
||||||
|
r#"string "{}" does not represent a valid integer"#,
|
||||||
|
trimmed
|
||||||
|
)),
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user