Ensure that reduce has a valid span (#4479)

This commit is contained in:
JT 2022-02-15 07:59:51 -05:00 committed by GitHub
parent 84f85ff9ae
commit 9114a2d31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -196,6 +196,7 @@ impl Command for Reduce {
v
}
})
.with_span(span)
.into_pipeline_data())
}
}

View File

@ -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",
)
}