diff --git a/crates/nu-command/src/conversions/into/int.rs b/crates/nu-command/src/conversions/into/int.rs index 7db84cff0f..4af37771d9 100644 --- a/crates/nu-command/src/conversions/into/int.rs +++ b/crates/nu-command/src/conversions/into/int.rs @@ -291,7 +291,7 @@ fn int_from_string(a_string: &str, span: Span) -> Result { }; Ok(num) } - _ => match a_string.parse::() { + _ => match trimmed.parse::() { Ok(n) => Ok(n), Err(_) => match a_string.parse::() { Ok(f) => Ok(f as i64), @@ -299,7 +299,10 @@ fn int_from_string(a_string: &str, span: Span) -> Result { "int".to_string(), "string".to_string(), span, - None, + Some(format!( + r#"string "{}" does not represent a valid integer"#, + trimmed + )), )), }, },