Properly handle commands defined inside of other commands (#2837)

* Fix function inner scopes

* tweak error
This commit is contained in:
Jonathan Turner
2021-01-01 19:23:54 +13:00
committed by GitHub
parent 328b09fe04
commit 43c10b0625
3 changed files with 74 additions and 6 deletions

View File

@ -380,6 +380,30 @@ fn run_custom_subcommand() {
assert_eq!(actual.out, "bobbob");
}
#[test]
fn run_inner_custom_command() {
let actual = nu!(
cwd: ".",
r#"
def outer [x] { def inner [y] { echo $y }; inner $x }; outer 10
"#
);
assert_eq!(actual.out, "10");
}
#[test]
fn run_broken_inner_custom_command() {
let actual = nu!(
cwd: ".",
r#"
def outer [x] { def inner [y] { echo $y }; inner $x }; inner 10
"#
);
assert!(actual.err.contains("not found"));
}
#[test]
fn set_variable() {
let actual = nu!(