Skip to content

nushell 0.86 regression: command option type and value is incorrectly inferred from default value #11033

@srackham

Description

@srackham

Describe the bug

In the following tests, explicitly typing an int option (--age) causes the next option (--name) to default to false instead of "foobar":

#[test]
def test-cmd1 [] {
    assert equal (cmd1) "foobar" # PASS
}

def cmd1 [
    --age = 0
    --name = "foobar"
] {
    $name   # "foobar"
}

#[test]
def test-cmd2 [] {
    assert equal (cmd2) "foobar" # FAIL
}

def cmd2 [
    --age: int = 0
    --name = "foobar"
] {
    $name   # false
}

#[test]
def test-cmd3 [] {
    assert equal (cmd3) "foobar" # FAIL
}

def cmd3 [
    --age: int
    --name = "foobar"
] {
    $name   # false
}

How to reproduce

Run the above tests.

Expected behavior

The above tests should pass.

Screenshots

No response

Configuration

key value
version 0.86.0
branch makepkg
commit_hash 5d8763e
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03) (Arch Linux rust 1:1.73.0-1)
cargo_version cargo 1.73.0
build_time 2023-10-18 08:45:09 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

Labels

A:parserIssues related to parsingA:type-systemProblems or features related to nushell's type systemcategory:bugSomething isn't workingcategory:regressionSomething that worked does not work anymore.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions