diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index e7a0c70c87..5451b87212 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -196,6 +196,7 @@ impl Command for Reduce { v } }) + .with_span(span) .into_pipeline_data()) } } diff --git a/src/tests/test_engine.rs b/src/tests/test_engine.rs index 43737b7e8c..5663526c6d 100644 --- a/src/tests/test_engine.rs +++ b/src/tests/test_engine.rs @@ -235,3 +235,11 @@ fn export_def_env() -> TestResult { fn dynamic_let_env() -> TestResult { run_test(r#"let x = "FOO"; let-env $x = "BAZ"; $env.FOO"#, "BAZ") } + +#[test] +fn reduce_spans() -> TestResult { + fail_test( + r#"let x = ([1, 2, 3] | reduce -f 0 { $it.item + 2 * $it.acc }); error make {msg: "oh that hurts", label: {text: "right here", start: (metadata $x).span.start, end: (metadata $x).span.end } }"#, + "right here", + ) +}