Skip to content

REPL panics when function has exactly 6 arguments #13930

@aionescu

Description

@aionescu

Describe the bug

When trying to call a function with exactly 6 arguments at the REPL, Nu panics when typing the 4th argument.

How to reproduce

Define the following function:

def f [a b c d e f] { }

Then, at the REPL, try calling it with the following parameters:

f 1 2 3

Trying to write any character after 3 (note the space) will cause Nu to panic with the message:

Error:   × Main thread panicked.                                                                                                                               
  ├─▶ at crates/nu-parser/src/parser.rs:926:28
  ╰─▶ index out of bounds: the len is 2 but the index is 3
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

The issue only occurs if f has exactly 6 parameters. The names and type signatures of the function and parameters don't seem to affect the outcome.

I've observed the issue on Nu v0.98.0, on both Linux and Android (Termux), and it occurs even with nu --no-config-file.

Expected behavior

I expect to be able to call the command as usual. For example, f 1 2 3 4 5 6.

Configuration

key value
version 0.98.0
major 0
minor 98
patch 0
branch makepkg
commit_hash 6e1e824
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.81.0 (eeb90cda1 2024-09-04) (Arch Linux rust 1:1.81.0-1)
cargo_version cargo 1.81.0 (2dbb1af80 2024-08-20)
build_time 2024-09-18 13:20:08 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:parserIssues related to parsingdeprecated:duplicate(deprecated: use GitHub's "close as duplicate" feature) This issue is a duplicate of another issuepanic

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions