mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 05:24:56 +02:00
Error on use path item1 item2
, if item1 is not a module (#11183)
# Description Fixes: #11143 # User-Facing Changes Take the following as example: ```nushell module foo { export def bar [] {}; export def baz [] {} } ``` `use foo bar baz` will be error: ``` ❯ use foo c d Error: nu::parser::wrong_import_pattern × Wrong import pattern structure. ╭─[entry #2:1:1] 1 │ use foo c d · ┬ · ╰── Trying to import something but the parent `c` is not a module, maybe you want to try `use <module> [<name1>, <name2>]` ╰──── ``` # Tests + Formatting Done
This commit is contained in:
@ -296,3 +296,18 @@ fn use_main_not_exported() {
|
||||
|
||||
assert!(actual.err.contains("external_command"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn use_sub_subname_error_if_not_from_submodule() {
|
||||
let inp = r#"module spam { export def foo [] {}; export def bar [] {} }; use spam foo bar"#;
|
||||
let actual = nu!(inp);
|
||||
assert!(actual.err.contains("try `use <module> [<name1>, <name2>]`"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_use_sub_subname_from_submodule() {
|
||||
let inp =
|
||||
r#"module spam { export module foo { export def bar [] {"bar"} } }; use spam foo bar; bar"#;
|
||||
let actual = nu!(inp);
|
||||
assert_eq!(actual.out, "bar")
|
||||
}
|
||||
|
Reference in New Issue
Block a user