Skip to content

Crash in parser when backspacing over variable name #9826

@sophiajt

Description

@sophiajt

Describe the bug

We currently crash when backspacing over the variable name in the following example:

let x = "foo" | $in; $x | describe

You get:

let xthread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/nu-parser/src/parser.rs:3068:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

How to reproduce

  1. Paste let x = "foo" | $in; $x | describe
  2. Move the cursor to the right of the x in let x
  3. Backspace and remove the x

Expected behavior

This should not crash

Screenshots

No response

Configuration

key value
version 0.83.1
branch main
commit_hash f8d325d
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.69.0 (84c898d65 2023-04-16)
rust_channel 1.69.0-aarch64-apple-darwin
cargo_version cargo 1.69.0 (6e9a83356 2023-04-12)
build_time 2023-07-28 05:55:14 +12:00
build_rust_channel debug
allocator standard
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:parserIssues related to parsingcategory:bugSomething isn't workingdeprecated: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