diff --git a/crates/nu-protocol/src/ast/expression.rs b/crates/nu-protocol/src/ast/expression.rs index 4818aa2db2..faf47d42ec 100644 --- a/crates/nu-protocol/src/ast/expression.rs +++ b/crates/nu-protocol/src/ast/expression.rs @@ -432,7 +432,17 @@ impl Expression { Expr::Int(_) => {} Expr::Float(_) => {} Expr::Binary(_) => {} - Expr::Range(_) => {} + Expr::Range(range) => { + if let Some(from) = &mut range.from { + from.replace_in_variable(working_set, new_var_id); + } + if let Some(next) = &mut range.next { + next.replace_in_variable(working_set, new_var_id); + } + if let Some(to) = &mut range.to { + to.replace_in_variable(working_set, new_var_id); + } + } Expr::Var(var_id) | Expr::VarDecl(var_id) => { if *var_id == IN_VARIABLE_ID { *var_id = new_var_id; diff --git a/tests/repl/test_engine.rs b/tests/repl/test_engine.rs index 1b74e741f7..0acc5957c3 100644 --- a/tests/repl/test_engine.rs +++ b/tests/repl/test_engine.rs @@ -75,6 +75,12 @@ fn in_used_twice_and_also_in_pipeline() -> TestResult { ) } +// #13441 +#[test] +fn in_used_in_range() -> TestResult { + run_test(r#"6 | 3..$in | math sum"#, "18") +} + #[test] fn help_works_with_missing_requirements() -> TestResult { run_test(r#"each --help | lines | length"#, "72")