diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 4d6509702..e7a9cef6b 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -58,7 +58,7 @@ pub fn eval_expression( Expr::Range(from, to, operator) => { // TODO: Embed the min/max into Range and set max to be the true max let from = if let Some(f) = from { - eval_expression(context, &f)? + eval_expression(context, f)? } else { Value::Int { val: 0i64, @@ -67,7 +67,7 @@ pub fn eval_expression( }; let to = if let Some(t) = to { - eval_expression(context, &t)? + eval_expression(context, t)? } else { Value::Int { val: 100i64, diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index bb9bea80c..3a0e600e9 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -738,14 +738,12 @@ pub fn parse_range( ), }; - let step_op_span = if let Some(pos) = step_op_pos { - Some(Span::new( + let step_op_span = step_op_pos.map(|pos| { + Span::new( span.start + pos, span.start + pos + "..".len(), // Only ".." is allowed for step operator - )) - } else { - None - }; + ) + }); let (range_op, range_op_str, range_op_span) = if let Some(pos) = token.find("..<") { if pos == range_op_pos { @@ -849,12 +847,10 @@ pub(crate) fn parse_dollar_expr( if contents.starts_with(b"$\"") { parse_string_interpolation(working_set, span) + } else if let (expr, None) = parse_range(working_set, span) { + (expr, None) } else { - if let (expr, None) = parse_range(working_set, span) { - (expr, None) - } else { - parse_variable_expr(working_set, span) - } + parse_variable_expr(working_set, span) } } diff --git a/crates/nu-protocol/src/value.rs b/crates/nu-protocol/src/value.rs index d1d72727c..d834bd320 100644 --- a/crates/nu-protocol/src/value.rs +++ b/crates/nu-protocol/src/value.rs @@ -239,7 +239,7 @@ impl Value { vals.iter() .map(|x| x.to_string()) .collect::>() - .join(", ".into()) + .join(", ") ) } Value::String { val, .. } => val,