Skip to content

nushell panics if I type let = if $ #9596

@WindSoilder

Description

@WindSoilder

Describe the bug

It happened when I have $env.x = if $, I want to replace it to let x = if $, then after I delete $env.x and type let, then nushell panics....

How to reproduce

Just type let = if $

Expected behavior

I expect nu to not panic..

Screenshots

No response

Configuration

key value
version 0.81.1
branch main
commit_hash a0dafcb
build_os macos-x86_64
build_target x86_64-apple-darwin
rust_version rustc 1.70.0 (90c541806 2023-05-31)
rust_channel stable-x86_64-apple-darwin
cargo_version cargo 1.70.0 (ec8a8a0ca 2023-04-25)
build_time 2023-06-23 18:19:13 +08:00
build_rust_channel release
allocator standard
features default, sqlite, trash, which, zip
installed_plugins from eml

Additional context

Here is my stack backtrace:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/nu-parser/src/parser.rs:3085:47                                                  07/03/2023 04:48:21 PM
stack backtrace:
   0:        0x103aec886 - std::backtrace_rs::backtrace::libunwind::trace::h0a908cd09b5a35f9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x103aec886 - std::backtrace_rs::backtrace::trace_unsynchronized::hc0e7d5d16c14a788
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x103aec886 - std::sys_common::backtrace::_print_fmt::hcf9ca6805c7eb2fe
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:        0x103aec886 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hae51cb91d407e2ef
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x103b13aeb - core::fmt::write::h746bc0969202388b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:        0x103ae690c - std::io::Write::write_fmt::h4098c2c7437a0bd7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:        0x103aec65a - std::sys_common::backtrace::_print::he6d3aef1f6c73e2d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:        0x103aec65a - std::sys_common::backtrace::print::h8360bf0158e89b36
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:        0x103aee800 - std::panicking::default_hook::{{closure}}::hedf04c568eb6e0bc
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:        0x103aee5b0 - std::panicking::default_hook::h62889b2c29e2347d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:        0x10144bf84 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha7fbf17f49c5c263
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  11:        0x10143673d - nu::main::{{closure}}::hcdde0b8cfc38dd18
                               at /Users/chenhongze/projects/rust_online_code/nushell/src/main.rs:56:9
  12:        0x103aeeeda - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5ccd129639ee877c
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  13:        0x103aeeeda - std::panicking::rust_panic_with_hook::h22edd02828aff274
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
  14:        0x103aeec74 - std::panicking::begin_panic_handler::{{closure}}::h6895f44a9b7e2caa
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  15:        0x103aeccc9 - std::sys_common::backtrace::__rust_end_short_backtrace::h013519e9b77978c5
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  16:        0x103aee9bd - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  17:        0x103b64a63 - core::panicking::panic_fmt::h2a51b60c12d11322
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  18:        0x103b64bb6 - core::panicking::panic_bounds_check::h0f21f6da46c4c9d2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:162:5
  19:        0x1027f1b3c - nu_parser::parser::parse_var_with_opt_type::h2468b2246e9d5787
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parser.rs:3085:47
  20:        0x102951b71 - nu_parser::parse_keywords::parse_let::h4f56d57adf36656b
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parse_keywords.rs:2842:25
  21:        0x10280836c - nu_parser::parser::parse_builtin_commands::haa83a3ad4a5762d1
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parser.rs:5142:19
  22:        0x10280b239 - nu_parser::parser::parse_pipeline::h8e58c8f931e06be7
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parser.rs:5422:36
  23:        0x10280c079 - nu_parser::parser::parse_block::h63e9472aeaa49be5
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parser.rs:5534:24
  24:        0x102811068 - nu_parser::parser::parse::hff0dc8b81f5aafea
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-parser/src/parser.rs:6038:13
  25:        0x1015ff462 - <nu_cli::syntax_highlight::NuHighlighter as reedline::highlighter::Highlighter>::highlight::h3e38cc4e73e07671
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-cli/src/syntax_highlight.rs:21:21
  26:        0x102581a17 - reedline::engine::Reedline::buffer_paint::h01367f8c6e6449e4
                               at /Users/chenhongze/.cargo/git/checkouts/reedline-e42026a78d91c510/2142c5c/src/engine.rs:1610:45
  27:        0x10257f718 - reedline::engine::Reedline::repaint::h9a5612aaacb6f59f
                               at /Users/chenhongze/.cargo/git/checkouts/reedline-e42026a78d91c510/2142c5c/src/engine.rs:1416:13
  28:        0x10257998e - reedline::engine::Reedline::read_line_helper::h1eb0133cf4ebd15f
                               at /Users/chenhongze/.cargo/git/checkouts/reedline-e42026a78d91c510/2142c5c/src/engine.rs:722:29
  29:        0x102578782 - reedline::engine::Reedline::read_line::hff5308cec8cf6f9e
                               at /Users/chenhongze/.cargo/git/checkouts/reedline-e42026a78d91c510/2142c5c/src/engine.rs:574:22
  30:        0x101634078 - nu_cli::repl::evaluate_repl::h155d9b63c5390e88
                               at /Users/chenhongze/projects/rust_online_code/nushell/crates/nu-cli/src/repl.rs:453:21
  31:        0x101442e70 - nu::run::run_repl::h3fdd312d68ae5d2c
                               at /Users/chenhongze/projects/rust_online_code/nushell/src/run.rs:243:19
  32:        0x101434057 - nu::main::hd43bb460b74fcca5
                               at /Users/chenhongze/projects/rust_online_code/nushell/src/main.rs:293:9
  33:        0x1014472ae - core::ops::function::FnOnce::call_once::ha2ff6822268b6cf4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  34:        0x10142f731 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbabf11ce878e131d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134:18
  35:        0x10142f7a4 - std::rt::lang_start::{{closure}}::hb450670fb81f213f
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:166:18
  36:        0x103adf9c2 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h4d31ab51fa4afcb3
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
  37:        0x103adf9c2 - std::panicking::try::do_call::h29870f82be4076a9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  38:        0x103adf9c2 - std::panicking::try::h5d28bc317561a503
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  39:        0x103adf9c2 - std::panic::catch_unwind::hcec89f8ee3292969
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  40:        0x103adf9c2 - std::rt::lang_start_internal::{{closure}}::h8aa82e7014dd312d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
  41:        0x103adf9c2 - std::panicking::try::do_call::hd2313fc9b34e2403
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  42:        0x103adf9c2 - std::panicking::try::hc5bb97f422b5bdd9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  43:        0x103adf9c2 - std::panic::catch_unwind::h8202c14898aaf8af
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  44:        0x103adf9c2 - std::rt::lang_start_internal::h36134e47b0b0d769
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
  45:        0x10142f777 - std::rt::lang_start::h1d2df3138f497a09
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:165:17
  46:        0x101435c08 - _main
  47:     0x7ff81838d41f - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions