From c2f8f4bd9b532e62631abfb2648c3df44b0445f3 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 12 Jul 2022 19:34:26 -0500 Subject: [PATCH] fix small bug converting string to int (#6031) --- crates/nu-command/src/conversions/into/int.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 + )), )), }, },