From 54d9fff4f285534810ce7174b76a74806327d205 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:38:16 -0700 Subject: [PATCH] Revert "Alias to keywords (eg `source`) (#4835)" (#4841) This reverts commit c023d4111a4d59ca6d423e484267916a898e6452. --- crates/nu-command/tests/commands/alias.rs | 13 ------------- crates/nu-command/tests/commands/mod.rs | 1 - crates/nu-parser/src/parser.rs | 17 ++++------------- tests/fixtures/formats/sample_def.nu | 3 --- 4 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 crates/nu-command/tests/commands/alias.rs delete mode 100644 tests/fixtures/formats/sample_def.nu diff --git a/crates/nu-command/tests/commands/alias.rs b/crates/nu-command/tests/commands/alias.rs deleted file mode 100644 index bb9cd3c27d..0000000000 --- a/crates/nu-command/tests/commands/alias.rs +++ /dev/null @@ -1,13 +0,0 @@ -use nu_test_support::{nu, pipeline}; - -#[test] -fn echo_range_is_lazy() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - alias bar = source sample_def.nu; bar; greet - "# - )); - - assert_eq!(actual.out, "hello"); -} diff --git a/crates/nu-command/tests/commands/mod.rs b/crates/nu-command/tests/commands/mod.rs index a3b2acd618..bb17eddad5 100644 --- a/crates/nu-command/tests/commands/mod.rs +++ b/crates/nu-command/tests/commands/mod.rs @@ -1,4 +1,3 @@ -mod alias; mod all; mod any; mod append; diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index b8c4f4de8c..99af7e60e6 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -897,19 +897,10 @@ pub fn parse_call( new_spans.extend(&spans[(pos + 1)..]); } - let alias_id = working_set.hide_alias(&name); - let lite_command = LiteCommand { - comments: vec![], - parts: new_spans.clone(), - }; - let (mut result, err) = parse_builtin_commands(working_set, &lite_command); - if let Some(frame) = working_set.delta.scope.last_mut() { - if let Some(alias_id) = alias_id { - frame.aliases.insert(name.clone(), alias_id); - } - } - - let mut result = result.expressions.remove(0); + working_set.enter_scope(); + working_set.hide_alias(&name); + let (mut result, err) = parse_expression(working_set, &new_spans, false); + working_set.exit_scope(); result.replace_span(working_set, expansion_span, orig_span); diff --git a/tests/fixtures/formats/sample_def.nu b/tests/fixtures/formats/sample_def.nu deleted file mode 100644 index a7f9a0602e..0000000000 --- a/tests/fixtures/formats/sample_def.nu +++ /dev/null @@ -1,3 +0,0 @@ -def greet [] { - "hello" -}