nushell/tests/shell/pipeline/commands
Wind 5596190377
do command: Make closure support default parameters and type checking (#12056)
# Description
Fixes: #11287
Fixes: #11318

It's implemented by porting the similar logic in `eval_call`, I've tried
to reduce duplicate code, but it seems that it's hard without using
macros.

3ee2fc60f9/crates/nu-engine/src/eval.rs (L60-L130)

It only works for `do` command.

# User-Facing Changes
## Closure supports optional parameter
```nushell
let code = {|x?| print ($x | default "i'm the default")}
do $code
```
Previously it raises an error, after this change, it prints `i'm the
default`.

## Closure supports type checking
```nushell
let code = {|x: int| echo $x}
do $code "aa"
```
After this change, it will raise an error with a message: `can't convert
string to int`

# Tests + Formatting
Done

# After Submitting
NaN
2024-03-11 18:11:08 +08:00
..
external.rs Don't expanding globs if user pass variables. (#11946) 2024-02-28 23:05:09 +08:00
internal.rs do command: Make closure support default parameters and type checking (#12056) 2024-03-11 18:11:08 +08:00
mod.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00