add more helpful error for calling a decl that exists in a module (#6752)

* add more helpful error for calling a decl that exists in a module

* accord to suggestions

* make error more helpful
This commit is contained in:
pwygab
2022-10-23 00:41:31 +08:00
committed by GitHub
parent 4fdf5c663c
commit 3f555a6836
3 changed files with 42 additions and 0 deletions

View File

@ -183,3 +183,17 @@ fn use_export_env_combined() {
assert_eq!(actual.out, "foo");
})
}
#[test]
fn use_module_creates_accurate_did_you_mean() {
let actual = nu!(
cwd: ".", pipeline(
r#"
module spam { export def foo [] { "foo" } }; use spam; foo
"#
)
);
assert!(actual.err.contains(
"command 'foo' was not found but it exists in module 'spam'; try using `spam foo`"
));
}