Skip to content

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

Closed

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

Activity

  1. changed the title [-]compile failed: can not parse string flags correctly[/-] [+]compile failed: can not parse string positional parameter/flags correctly[/+] on Apr 7, 2023
  2. fdncred commented on Apr 7, 2023

    @fdncred
    Contributor

    Your number-like things need to be in quotes. The release notes for 0.78.0 reference the PR that caused this breaking change https://www.nushell.sh/blog/2023-04-04-nushell_0_78.html#bare-words-can-t-start-with-a-number

  3. lost22git commented on Apr 7, 2023

    @lost22git
    Author

    Pay attention to my code, I have added quotation marks, but I still get an error

  4. lost22git commented on Apr 7, 2023

    @lost22git
    Author

    Nushell's design is getting more and more difficult to understand

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions