nushell / nushell

A new type of shell
https://www.nushell.sh/
MIT License
31.61k stars 1.62k forks source link

reloading a module and triggering a completion in the same line causes panic #6001

Open aikow opened 2 years ago

aikow commented 2 years ago

Describe the bug

I'm currently working on a module, and in order to test it more quickly, I combined the command to load the module, and run a function from it into a single line. Now, triggering tab completion for that line, causes nu to panic and crash completely

How to reproduce

zoo.nu

def animals [] { [cat dog cow axolotl] }

export def say [
  animal: string@animals
] {
  $animal
}
> use zoo.nu *
> say c<tab>at
cat
(tab completion works)
> use zoo.nu *; say <tab>thread 'main' panicked at 'internal error: missing declaration', crates/nu-protocol/src/engine/engin
e_state.rs:597:14
stack backtrace:
   0:     0x5631d874df42 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8f618991fbf64972
   1:     0x5631d7748d6c - core::fmt::write::hc69b5b640d88cce8
   2:     0x5631d8746181 - std::io::Write::write_fmt::h3403cef06a24a303
   3:     0x5631d874fbb5 - std::panicking::default_hook::{{closure}}::h48ed2c3707d5e20e
   4:     0x5631d874f8e9 - std::panicking::default_hook::h8744fc5cea5e3110
   5:     0x5631d87501be - std::panicking::rust_panic_with_hook::hc82286af2030e925
   6:     0x5631d874ffe4 - std::panicking::begin_panic_handler::{{closure}}::h1c15057c2f09081f
   7:     0x5631d874e454 - std::sys_common::backtrace::__rust_end_short_backtrace::h65de906a5330f8da
   8:     0x5631d874fd4d - rust_begin_unwind
   9:     0x5631d72cd5e3 - core::panicking::panic_fmt::h741cfbfc95bc6112
  10:     0x5631d7745fa1 - core::panicking::panic_display::h1094c8c253f473c8
  11:     0x5631d7745f4b - core::panicking::panic_str::hbdaf98ecbcb31da3
  12:     0x5631d72cd456 - core::option::expect_failed::hf79a0c6dca04c0cf
  13:     0x5631d7cba6cc - nu_engine::eval::eval_call::hf54f3952a01dc756
  14:     0x5631d78642c7 - <nu_cli::completions::custom_completions::CustomCompletion as nu_cli::completions::base::Completer>::fetch::h3b417
66bfc54f635
  15:     0x5631d78a2a98 - <nu_cli::completions::completer::NuCompleter as reedline::completion::base::Completer>::complete::hfdd167ea044f64e
7
  16:     0x5631d85c8b79 - <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::update_values::h783635491b625328
  17:     0x5631d85c0a1f - reedline::engine::Reedline::handle_editor_event::habd89db60ddab62f
  18:     0x5631d85c068b - reedline::engine::Reedline::handle_editor_event::habd89db60ddab62f
  19:     0x5631d85bf3f6 - reedline::engine::Reedline::read_line::h6947a3484865de8c
  20:     0x5631d7887059 - nu_cli::repl::evaluate_repl::h0a929550ab0f6594
  21:     0x5631d783a6e4 - nu::main::hed3c44a5544c0b6f
  22:     0x5631d7846e9f - std::sys_common::backtrace::__rust_begin_short_backtrace::h0caab71fc9e9a24b
  23:     0x5631d784e301 - std::rt::lang_start::{{closure}}::hf8ee96b5e1592366
  24:     0x5631d873e6ce - std::rt::lang_start_internal::h1899cfd715ca6829
  25:     0x5631d783c252 - main
  26:     0x7fca7501d290 - <unknown>
  27:     0x7fca7501d34a - __libc_start_main
  28:     0x5631d7316e85 - _start
  29:                0x0 - <unknown>

Expected behavior

Mostly just not crash, and somehow recover. I'll freely admit that this is a relatively weird edge use case :joy:.

Screenshots

No response

Configuration

key value
version 0.65.1
branch
commit_hash de162c9aea944b821a4dbd806ad535732d9d87f6
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.62.0 (a8314ef7d 2022-06-27)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.62.0 (a748cf5a3 2022-06-08)
pkg_version 0.65.1
build_time 2022-07-06 06:28:19 +02:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

Kangaxx-0 commented 2 years ago

After the first completion cat, how to reproduce this error? Tried use zoo.nu * but did not panick

aikow commented 2 years ago

you have to separate the second command with the semicolon, typing it all on one line.

> use zoo.nu *; zoo <tab>

triggering a completion in the second part after zoo.