-
Notifications
You must be signed in to change notification settings - Fork 2.1k
closures and commands don't treat optional parameters the same #11287
Copy link
Copy link
Closed
Labels
status:needs-triageAn issue that hasn't had any proper lookAn issue that hasn't had any proper look
Milestone
Description
related to
Describe the bug
as per title
How to reproduce
- run
let code = {|x?| print ($x | default "i'm the default")}
do $code- see the following error
Error: nu::shell::variable_not_found
× Variable not found
╭─[entry #7:1:1]
1 │ let code = {|x?| print ($x | default "i'm the default")}
· ─┬
· ╰── variable not found
2 │ do $code
╰────
- run
def foo [x?] { print ($x | default "i'm the default") }
foo- see the expected output, i.e.
i'm the default
Expected behavior
because closures and commands are so similar, i.e. closures are basically unnamed commands, i expected running
let code = {|x?| print ($x | default "i'm the default")}
do $codeto show
i'm the default
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.87.1 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.73.0 (cc66ad468 2023-10-03) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.73.0 (9c4383fb5 2023-08-26) |
| build_time | 2023-11-21 18:26:35 +01:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, trash, which, zip |
| installed_plugins | clipboard copy, clipboard paste, gstat, notify, nu_plugin_explore, query git |
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status:needs-triageAn issue that hasn't had any proper lookAn issue that hasn't had any proper look