Skip to content

parser panicked with index out of bounds #8385

Closed

Description

@ahkrr

Describe the bug

I created a function with a signature that would lead to the parser panicking when I tried to type out specific ways of calling the function.
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 3', crates/nu-parser/src/parser.rs:752:28

How to reproduce

  1. def nuu [ one: list two: list three: list four: list five: list six: list ] { }
  2. nuu [] [] [] [] [] [] # trying to type out this call would lead to a panic!
  3. nuu 0 0 0 0 # trying to type out this call would lead to a panic!
  4. nuu 00 00 00 00 00 # trying to type out this call would lead to a panic!

Expected behavior

I expected nu to not panci!

Screenshots

No response

Configuration

key value
version 0.76.0
branch
commit_hash bc38a6a
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10)
rust_channel 1.66.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
pkg_version 0.76.0
build_time 2023-02-21 21:13:21 +00:00
build_rust_channel release
features database, default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. fdncred commented on Mar 10, 2023

    @fdncred
    Contributor

    Hey @ahkrr, Glad to see you back here. Do you know if this problem still exists in the latest main?

  2. ahkrr commented on Mar 10, 2023

    @ahkrr
    ContributorAuthor
    key value
    version 0.76.1
    branch main
    commit_hash 878e08c
    build_os linux-x86_64
    build_target x86_64-unknown-linux-gnu
    rust_version rustc 1.66.1 (90743e729 2023-01-10)
    rust_channel 1.66.1-x86_64-unknown-linux-gnu
    cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
    build_time 2023-03-10 14:33:32 +01:00
    build_rust_channel release
    features default, zip
    installed_plugins

    still has this error
    thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 3', crates/nu-parser/src/parser.rs:767:28

  3. added
    category:bug
    on Mar 10, 2023
  4. added
    A:parser
    on Oct 15, 2023
  5. sblundy commented on Jan 3, 2024

    @sblundy

    I'm experiencing this in 0.88.1

    How to reproduce

    1. Save the following as repro.nu
      export def "dynamic-profiles add-parent" [
        --name: string
        --guid: string
        --title-components: int
        --custom-directory
        dir: directory
        parent_name: string
        tag: string
      ]: nothing -> nothing {
        echo $dir
      }
      
    2. Enter the following commands
      with-env { RUST_BACKTRACE:'full' } { nu }
      use repro.nu
      
    3. Type the follow
      repro dynamic-profiles add-parent --guid 57C8C3F9-9B14-4480-8CD0-D11E233A8999 --name n -
      
    4. When I type the final -, I get this error
       thread 'main' panicked at crates/nu-parser/src/parser.rs:740:28:
       index out of bounds: the len is 3 but the index is 4
       stack backtrace:
          0:        0x103eb9980 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb1669d376cd16fb9
          1:        0x102271238 - core::fmt::write::hfb70cbdb2260ac51
          2:        0x103eae13c - std::io::Write::write_fmt::h70ee144642a582c5
          3:        0x103eb9790 - std::sys_common::backtrace::print::h404168d6289bebbe
          4:        0x103ea482c - std::panicking::default_hook::{{closure}}::hcad9841f2663dad9
          5:        0x103ea45c0 - std::panicking::default_hook::he7ca7c46dc216a28
          6:        0x103ea4ddc - std::panicking::rust_panic_with_hook::h501076dcf33dacb0
          7:        0x103eb9df4 - std::panicking::begin_panic_handler::{{closure}}::h0665b0808da4d87c
          8:        0x103eb9ba4 - std::sys_common::backtrace::__rust_end_short_backtrace::h6d7b13146df55e47
          9:        0x103ea4a4c - _rust_begin_unwind
         10:        0x104109c40 - core::panicking::panic_fmt::h5de4b603c189570c
         11:        0x104109d84 - core::panicking::panic_bounds_check::h118ceae1ab7525f1
         12:        0x102942f38 - nu_parser::parser::parse_multispan_value::h67241b95e9ceb221
         13:        0x102944bf8 - nu_parser::parser::parse_internal_call::hb9d46c4649a450a4
         14:        0x102945bdc - nu_parser::parser::parse_call::had6f906ccc6a74e2
         15:        0x102958224 - nu_parser::parser::parse_expression::hb2075bebc9030df3
         16:        0x102959424 - nu_parser::parser::parse_builtin_commands::hef5b2f52fbc25272
         17:        0x10295a5b0 - nu_parser::parser::parse_block::h4f357b2b7d600578
         18:        0x10295d2f8 - nu_parser::parser::parse::h8f50b85856031cea
         19:        0x1023a596c - <nu_cli::syntax_highlight::NuHighlighter as reedline::highlighter::Highlighter>::highlight::h906629ac0cb0121c
         20:        0x103d2d0c4 - reedline::engine::Reedline::repaint::h99af94e7bd241818
         21:        0x103d2a7f4 - reedline::engine::Reedline::read_line::h365dfe0f0dd70edc
         22:        0x102374e2c - nu_cli::repl::evaluate_repl::h614447b1abdcbde4
         23:        0x10235f7a8 - nu::run::run_repl::h464f73c8c6a48e5b
         24:        0x102352fbc - nu::main::h54fa68165e70c11a
         25:        0x102361c40 - std::sys_common::backtrace::__rust_begin_short_backtrace::h04a4194c8c76c275
         26:        0x10235cd5c - std::rt::lang_start::{{closure}}::hc86c705c567b2529
         27:        0x103ea496c - std::panicking::try::h8fbeda15452e3045
         28:        0x103e99ea4 - std::rt::lang_start_internal::h74e1b60c5b4153f8
         29:        0x102353c24 - _main
      

    Configuration

    key value
    version 0.88.1
    branch
    commit_hash
    build_os macos-aarch64
    build_target aarch64-apple-darwin
    rust_version rustc 1.74.0 (79e9716c9 2023-11-13) (Homebrew)
    cargo_version cargo 1.74.0
    build_time 2023-12-14 17:14:47 +00:00
    build_rust_channel release
    allocator mimalloc
    features dataframe, default, sqlite, trash, which, zip
    installed_plugins inc
  6. added this to the v0.99.0 milestone on Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:parsercategory:bugpanic

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions