diff --git a/crates/nu-command/tests/commands/do_.rs b/crates/nu-command/tests/commands/do_.rs index 6a71a0f025..5f46b02c17 100644 --- a/crates/nu-command/tests/commands/do_.rs +++ b/crates/nu-command/tests/commands/do_.rs @@ -66,3 +66,10 @@ fn ignore_error_works_with_list_stream() { let actual = nu!(r#"do -i { ["a", null, "b"] | ansi strip }"#); assert!(actual.err.is_empty()); } + +#[test] +fn run_closure_with_it_using() { + let actual = nu!(r#"let x = {let it = 3; $it}; do $x"#); + assert!(actual.err.is_empty()); + assert_eq!(actual.out, "3"); +} diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index bd09f5b52a..fb36e8b503 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -4177,20 +4177,6 @@ pub fn parse_block_expression(working_set: &mut StateWorkingSet, span: Span) -> if let Some(signature) = signature { output.signature = signature.0; - } else if let Some(last) = working_set.delta.scope.last() { - // FIXME: this only supports the top $it. Is this sufficient? - - if let Some(var_id) = last.get_var(b"$it") { - let mut signature = Signature::new(""); - signature.required_positional.push(PositionalArg { - var_id: Some(*var_id), - name: "$it".into(), - desc: String::new(), - shape: SyntaxShape::Any, - default_value: None, - }); - output.signature = Box::new(signature); - } } output.span = Some(span); @@ -4518,20 +4504,6 @@ pub fn parse_closure_expression( if let Some(signature) = signature { output.signature = signature.0; - } else if let Some(last) = working_set.delta.scope.last() { - // FIXME: this only supports the top $it. Is this sufficient? - - if let Some(var_id) = last.get_var(b"$it") { - let mut signature = Signature::new(""); - signature.required_positional.push(PositionalArg { - var_id: Some(*var_id), - name: "$it".into(), - desc: String::new(), - shape: SyntaxShape::Any, - default_value: None, - }); - output.signature = Box::new(signature); - } } output.span = Some(span);