mirror of
https://github.com/nushell/nushell
synced 2025-01-13 21:55:07 +00:00
Fix open ended ranges (#4677)
* Make open ended ranges more open ended * Add test
This commit is contained in:
parent
b09acdb7f9
commit
cb5c61d217
3 changed files with 12 additions and 2 deletions
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue