Skip to content

compile failed: can not parse string positional parameter/flags correctly #8788

@lost22git

Description

@lost22git

Describe the bug

╰─❯ open test.nu
def main [
  word:string
  --option (-o):string=''
  --flag (-f)
] {
  print $'word=($word) option=($option) flag=($flag)'
}

╰─❯ nu test.nu hello -f -o '1'
Error: nu::parser::type_mismatch

  × Type mismatch during operation.
   ╭─[<commandline>:1:1]
 1 │ main hello -f -o 1
   ·                  ┬
   ·                  ╰── expected string, found number-like value (hint: use quotes or backticks)
   ╰────

╰─❯ nu test.nu '1' -f -o '1'
Error: nu::parser::type_mismatch

  × Type mismatch during operation.
   ╭─[<commandline>:1:1]
 1 │ main 1 -f -o 1
   ·      ┬
   ·      ╰── expected string, found number-like value (hint: use quotes or backticks)
   ╰────

How to reproduce

as above

Expected behavior

print word=hello option=1 flag=true

Screenshots

No response

Configuration

key value
version 0.78.0
branch
commit_hash
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.69.0-nightly (f77bfb733 2023-03-01)
rust_channel nightly-x86_64-pc-windows-msvc
cargo_version cargo 1.69.0-nightly (9880b408a 2023-02-28)
build_time 2023-04-06 11:19:15 +08:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions