Skip to content

Cannot provide default values for list arguments #8092

Closed

Description

@aidalgol

Describe the bug

It is impossible to define a command with an argument of type list and a default value.

How to reproduce

Evaluate the following in a nu shell:

def my-cmd [
  foo: list = ["junk"]
] {
  echo ($foo | str join ,)
}

Which will produce the following error

Error: nu::parser::assignment_mismatch (link)

  × Default value wrong type
   ╭─[entry #7:1:1]
 1 │ def my-cmd [
 2 │   foo: list = ["junk"]
   ·               ────┬───
   ·                   ╰── default value not list<any>
 3 │ ] {
   ╰────

Expected behavior

The command my-cmd would be defined and take an optional list argument that defaults to the list value ["junk"].

Screenshots

No response

Configuration

key value
version 0.75.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10) (built from a source tarball)
cargo_version cargo 1.66.1
pkg_version 0.75.0
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
features database, default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. added
    A:parser
    on Feb 16, 2023
  2. amtoine commented on Feb 19, 2023

    @amtoine
    Member

    this looks related to #8109, isn't it?

    i've tested #8096 and it looks it's working fine now 😌

  3. added a commit that references this issue on Feb 22, 2023
    58829e3
  4. amtoine commented on Feb 22, 2023

    @amtoine
    Member

    it works indeed 👌

  5. added this to the v0.77.0 milestone on Feb 23, 2023
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:parser

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions