Skip to content

Syntax-hightlight panics with index out of bounds due to custom function with many arguments #9072

@ghost

Description

Describe the bug

The interactive shell panics during typing when calling a custom function with many arguments:

(stacktrace from RUST_BACKTRACE=full nu -> reproduction steps)

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 3', crates/nu-parser/src/parser.rs:737:28
stack backtrace:
   0:     0x561699d32165 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3155a8c966b4beb5
   1:     0x5616991a19fe - core::fmt::write::h062c617411b691df
   2:     0x561699d2a7f5 - std::io::Write::write_fmt::hb61fdf1275c61e1c
   3:     0x561699d31f35 - std::sys_common::backtrace::print::hca896ae22beb06cb
   4:     0x561699d33cbf - std::panicking::default_hook::{{closure}}::h0b5eeed5cf36ab5f
   5:     0x561699d33a2a - std::panicking::default_hook::h8932b573145a321b
   6:     0x561699d34350 - std::panicking::rust_panic_with_hook::h4b1447a24e3e94f8
   7:     0x561699d340e4 - std::panicking::begin_panic_handler::{{closure}}::h8701da9995a3820c
   8:     0x561699d3267c - std::sys_common::backtrace::__rust_end_short_backtrace::hb696c5ed02a01598
   9:     0x561699d33e32 - rust_begin_unwind
  10:     0x56169913abd3 - core::panicking::panic_fmt::h8aa706a976963c88
  11:     0x56169913ad22 - core::panicking::panic_bounds_check::he585f6a1f703448f
  12:     0x5616997b98ed - nu_parser::parser::parse_multispan_value::h67d8f1193d506532
  13:     0x5616997bb64d - nu_parser::parser::parse_internal_call::hc113520e17e3a887
  14:     0x5616997bdbda - nu_parser::parser::parse_call::h1f0bbfcb84b7667b
  15:     0x5616997d1edd - nu_parser::parser::parse_expression::hffcd304ab2ee2251
  16:     0x5616997d3ccb - nu_parser::parser::parse_block::h99ebe3033fbe971b
  17:     0x5616997d6505 - nu_parser::parser::parse::h102b5a6027e18c2b
  18:     0x5616992bd413 - <nu_cli::syntax_highlight::NuHighlighter as reedline::highlighter::Highlighter>::highlight::h19d6e3bee963c6e7
  19:     0x561699c7cbc5 - reedline::engine::Reedline::repaint::hdce1b55e1695012e
  20:     0x561699c796fb - reedline::engine::Reedline::read_line::h14782f212db6dba8
  21:     0x5616992a7951 - nu_cli::repl::evaluate_repl::h8fa62efc712f0283
  22:     0x56169925d6e8 - nu::run::run_repl::h099d0965c85cccb8
  23:     0x56169926d6ce - nu::main::h6874178a2c9fda2d
  24:     0x56169925dbec - std::sys_common::backtrace::__rust_begin_short_backtrace::h25965459592b9f02
  25:     0x56169925fb9a - std::rt::lang_start::{{closure}}::h3ffff9d791fa9fb7
  26:     0x561699d2424b - std::rt::lang_start_internal::hcd7e45acd25ab5ab
  27:     0x56169926e3f5 - main
  28:     0x7f4f3cabdd90 - <unknown>
  29:     0x7f4f3cabde40 - __libc_start_main
  30:     0x56169915f53e - _start
  31:                0x0 - <unknown>

How to reproduce

  1. def a [b: bool, c: bool, d: float, e: float, f: float, g: float] {} (5 arguments are fine - not sure if the datatype matters)
  2. a true true 1 1 -> panics without any further input

Expected behavior

i expect nu to let me fill out the command and run the function

Screenshots

No response

Configuration

key value
version 0.79.0
branch
commit_hash a1b7261
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-04-25 20:26:29 +00:00
build_rust_channel release
features default, zip
installed_plugins

system: canonical-multipass ubuntu22.04 vm
env.nu: empty file
config.nu: empty file

Additional context

No response

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