From 24cd1b591c2422ab6048ad90d7beacee542cec8e Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 27 Aug 2021 14:30:10 +1200 Subject: [PATCH] Update todo --- TODO.md | 4 ++++ crates/nu-engine/src/eval.rs | 11 ++++++----- crates/nu-engine/src/value.rs | 11 ++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 9e0122441b..3bee469d99 100644 --- a/TODO.md +++ b/TODO.md @@ -11,12 +11,16 @@ - [x] refactor into subcrates - [x] subcommand alias - [x] type inference from successful parse (eg not `List` but `List`) +- [ ] parsing tables +- [ ] ...rest without calling it rest +- [ ] operator overflow - [ ] finish operator type-checking - [ ] Column path - [ ] Ranges - [ ] Source - [ ] Autoenv - [ ] Block params +- [ ] let [first, rest] = [1, 2, 3] ## Maybe: - [ ] default param values? diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index aec3786c4c..7cd7d32dc3 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -34,11 +34,12 @@ fn eval_call(state: &State, call: &Call) -> Result { let decl = parser_state.get_decl(call.decl_id); if let Some(block_id) = decl.body { let state = state.enter_scope(); - for (arg, param) in call - .positional - .iter() - .zip(decl.signature.required_positional.iter()) - { + for (arg, param) in call.positional.iter().zip( + decl.signature + .required_positional + .iter() + .chain(decl.signature.optional_positional.iter()), + ) { let result = eval_expression(&state, arg)?; let var_id = param .var_id diff --git a/crates/nu-engine/src/value.rs b/crates/nu-engine/src/value.rs index c5a200a957..b4e9bdb921 100644 --- a/crates/nu-engine/src/value.rs +++ b/crates/nu-engine/src/value.rs @@ -89,7 +89,16 @@ impl Display for Value { write!(f, "{}", val) } Value::String { val, .. } => write!(f, "{}", val), - Value::List { .. } => write!(f, ""), + Value::List { val, .. } => { + write!( + f, + "[{}]", + val.iter() + .map(|x| x.to_string()) + .collect::>() + .join(", ".into()) + ) + } Value::Block { .. } => write!(f, ""), Value::Nothing { .. } => write!(f, ""), }