-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Cannot provide default values for list arguments #8092
Copy link
Copy link
Closed
Labels
A:parserIssues related to parsingIssues related to parsing
Milestone
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A:parserIssues related to parsingIssues related to parsing