Skip to content

Cusom command: default value shouldn't restrict argument's type #10410

@WindSoilder

Description

@WindSoilder

Describe the bug

Notice that when we define a custom command's argument with default value, the type of argument will be bounded.

How to reproduce

Run the following script:

def a [b: any = null] { print ($b == null) }
a 3

Then nushell throws the following error:

Error: nu::parser::parse_mismatch_with_full_string_msg

  × Parse mismatch during operation.
   ╭─[entry #16:1:1]
 1  def a [b: any = null] { print ($b == null) }
 2  a 3
   ·   
   ·   ╰── expected nothing
   ╰────

Expected behavior

I expected nu to print false

Screenshots

No response

Configuration

key value
version 0.84.1
branch main
commit_hash 715c157
build_os macos-x86_64
build_target x86_64-apple-darwin
rust_version rustc 1.70.0 (90c541806 2023-05-31)
rust_channel stable-x86_64-apple-darwin
cargo_version cargo 1.70.0 (ec8a8a0ca 2023-04-25)
build_time 2023-08-29 16:48:30 +08:00
build_rust_channel release
allocator standard
features default, extra, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:type-systemProblems or features related to nushell's type systemstatus:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions