Fix open ended ranges (#4677)

* Make open ended ranges more open ended

* Add test
This commit is contained in:
JT 2022-02-28 11:15:31 -05:00 committed by GitHub
parent b09acdb7f9
commit cb5c61d217
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -138,6 +138,11 @@ impl Command for Table {
let base_pipeline = val.to_base_value(span)?.into_pipeline_data();
self.run(engine_state, stack, call, base_pipeline)
}
PipelineData::Value(x @ Value::Range { .. }, ..) => Ok(Value::String {
val: x.into_string("", &config),
span: call.head,
}
.into_pipeline_data()),
x => Ok(x),
}
}

View file

@ -37,12 +37,12 @@ impl Range {
let to = if let Value::Nothing { .. } = to {
if let Ok(Value::Bool { val: true, .. }) = next.lt(expr_span, &from) {
Value::Int {
val: -100i64,
val: i64::MIN,
span: expr_span,
}
} else {
Value::Int {
val: 100i64,
val: i64::MAX,
span: expr_span,
}
}

View file

@ -272,3 +272,8 @@ fn shortcircuiting_and() -> TestResult {
fn shortcircuiting_or() -> TestResult {
run_test(r#"$true || (5 / 0; $false)"#, "true")
}
#[test]
fn open_ended_range() -> TestResult {
run_test(r#"1.. | first 100000 | length"#, "100000")
}