nushell / nushell/nushell

importing non-existing subcommand from module is possible

Open
#10,618 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:error-unhelpful A:parser A:scoping/name-resolution category:bug
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

as title

How to reproduce
with std
  1. run nu -n to not load std clip by default
  2. run use std clip foo
  3. clip can be run
with a module
  1. define the foo module
module foo { export def bar [] {} }
  1. import foo bar with a trailing garbage
use foo bar brr
  1. bar can be run
Expected behavior
with std

i expected something like

Error: nu::parser::export_not_found

  × Export not found.
   ╭─[entry #17:1:1]
 1 │ use std "clip foo"
   ·         ─────┬────
   ·              ╰── could not find imports
   ╰────

or

Error: nu::parser::export_not_found

  × Export not found.
   ╭─[entry #18:1:1]
 1 │ use std foo
   ·         ─┬─
   ·          ╰── could not find imports
   ╰────
with a module

same expectations

Screenshots

No response

Configuration
key value
version 0.85.1
branch main
commit_hash 8c507dc984693c45b0440adf63a94e0410b4bc42
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.70.0 (90c541806 2023-05-31)
rust_channel 1.70.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.70.0 (ec8a8a0ca 2023-04-25)
build_time 2023-10-04 18:35:49 +02:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins gstat, nu_plugin_explore
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with nu -n, use std clip foo, and the foo module example using use foo bar brr. Trace the parser entry point for use imports and verify that trailing or nonexistent exports produce an export_not_found error rather than making the valid command available.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.