diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 07ab35dc36..d71ef77182 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1532,7 +1532,9 @@ pub fn parse_int(working_set: &mut StateWorkingSet, span: Span) -> Expression { span: Span, radix: u32, ) -> Expression { - if let Ok(num) = i64::from_str_radix(token, radix) { + // Parse as a u64, then cast to i64, otherwise, for numbers like "0xffffffffffffffef", + // you'll get `Error parsing hex string: number too large to fit in target type`. + if let Ok(num) = u64::from_str_radix(token, radix).map(|val| val as i64) { Expression::new(working_set, Expr::Int(num), span, Type::Int) } else { working_set.error(ParseError::InvalidLiteral(