From eb67eab1228c46c9f3049de3f89a7f65e59616b9 Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 13 Sep 2021 19:31:11 +1200 Subject: [PATCH] WIP --- crates/nu-parser/src/parser.rs | 24 ++++++++++++++---------- crates/nu-protocol/src/syntax_shape.rs | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index dde250716b..7a7c09db98 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1030,17 +1030,20 @@ pub fn parse_variable_expr( None, ) } else { - let name = working_set.get_span_contents(span).to_vec(); + // let name = working_set.get_span_contents(span).to_vec(); // this seems okay to set it to unknown here, but we should double-check - let id = working_set.add_variable(name, Type::Unknown); - ( - Expression { - expr: Expr::Var(id), - span, - ty: Type::Unknown, - }, - None, - ) + //let id = working_set.add_variable(name, Type::Unknown); + // ( + // Expression { + // expr: Expr::Var(id), + // span, + // ty: Type::Unknown, + // }, + // None, + // ) + // } else { + (garbage(span), err) + // } } } else { (garbage(span), err) @@ -1995,6 +1998,7 @@ pub fn parse_block_expression( output.signature = signature; } else if let Some(last) = working_set.delta.scope.last() { // FIXME: this only supports the top $it. Instead, we should look for a free $it in the expression. + if let Some(var_id) = last.get_var(b"$it") { let mut signature = Signature::new(""); signature.required_positional.push(PositionalArg { diff --git a/crates/nu-protocol/src/syntax_shape.rs b/crates/nu-protocol/src/syntax_shape.rs index 3e3337cd0f..bee2450a8a 100644 --- a/crates/nu-protocol/src/syntax_shape.rs +++ b/crates/nu-protocol/src/syntax_shape.rs @@ -34,7 +34,7 @@ pub enum SyntaxShape { GlobPattern, /// A block is allowed, eg `{start this thing}` - Block, + Block(Vec<(Vec, SyntaxShape)>), /// A table is allowed, eg `[[first, second]; [1, 2]]` Table,