-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Cant append list<type> in list<any> using ++= operator #8153
Copy link
Copy link
Closed
Labels
A:type-systemProblems or features related to nushell's type systemProblems or features related to nushell's type systemcategory:bugSomething isn't workingSomething isn't workingcategory:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected
Milestone
Description
Describe the bug
I created a mutable list which contains strings and paths at initialisation.
I want to append more items in the list using the ++= operator but the script won't compile, nu telling me it cant append list in list.
How to reproduce
Compile this :
mut args = [
hello # string type
("hello" | path join world) # path type
]
# => args is list<any>
$args ++= [ foo bar ] # only strings
Nushell raise an error :
Error: nu::parser::type_mismatch (link)
× Type mismatch during operation.
╭─[C:\Users\glitc\Projects\scripts-util\test.nu:8:1]
8 │ ]
9 │ $args ++= [ foo bar ]
· ─────┬─────
· ╰── expected list<any>, found list<string>
10 │ $args
╰────
Expected behavior
Being able to append list of any fixed type (e.g. list<string>, list<int>, list<path>, ...) in a list<any>
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.75.0 |
| branch | |
| commit_hash | 17a265b |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.66.1 (90743e729 2023-01-10) |
| rust_channel | 1.66.1-x86_64-pc-windows-msvc |
| cargo_version | cargo 1.66.1 (ad779e08b 2023-01-10) |
| pkg_version | 0.75.0 |
| build_time | 2023-02-01 08:01:00 -06:00 |
| build_rust_channel | release |
| features | database, default, trash, which, zip |
| installed_plugins |
Additional context
In my example above, replacing $args ++= [ foo bar ] by $args = $args ++ [ foo bar ] works well
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A:type-systemProblems or features related to nushell's type systemProblems or features related to nushell's type systemcategory:bugSomething isn't workingSomething isn't workingcategory:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected