Skip to content

Error on use path item1 item2, if item1 is not a module#11183

Merged
sholderbach merged 3 commits intonushell:mainfrom
WindSoilder:error_on_not_proper_use
Dec 5, 2023
Merged

Error on use path item1 item2, if item1 is not a module#11183
sholderbach merged 3 commits intonushell:mainfrom
WindSoilder:error_on_not_proper_use

Conversation

@WindSoilder
Copy link
Copy Markdown
Contributor

Description

Fixes: #11143

User-Facing Changes

Take the following as example:

module foo { export def bar [] {}; export def baz [] {} }

use foo bar baz will be error:

❯ use foo bar baz
Error: nu::parser::wrong_import_pattern

  × Wrong import pattern structure.
   ╭─[entry #11:1:1]
 1 │ use foo bar baz
   ·             ─┬─
   ·              ╰── You can only use sub-sub names from sub modules, but `bar` is not a module
   ╰────

Tests + Formatting

Done

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Nov 29, 2023

very nice

use std "path add" foo bar
Error: nu::parser::wrong_import_pattern

  × Wrong import pattern structure.
   ╭─[entry #2:1:1]
 1 │ use std "path add" foo bar
   ·                    ─┬─
   ·                     ╰── You can only use sub-sub names from sub modules, but `path add` is not a module
   ╰────

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Nov 30, 2023

thanks @WindSoilder for fixing this 🙏

i'm ok with the changes 👌
once the review thread of @sholderbach is closed, feel free to land anytime 😌

@sholderbach sholderbach merged commit fb3350e into nushell:main Dec 5, 2023
@WindSoilder WindSoilder deleted the error_on_not_proper_use branch December 8, 2023 08:56
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
)

# Description
Fixes: nushell#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 nushell#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
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
)

# Description
Fixes: nushell#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 nushell#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use path item1 item2 syntax isn't prohibited, but item2 isn't brought into scope

3 participants