mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 09:59:00 +02:00
enable flag value type checking (#11311)
# Description Fixes: #11310 # User-Facing Changes After the change, the following code will go to error: ```nushell > def a [--x: int = 3] { "aa" } > let y = "aa" > a --x=$y Error: nu::parser::type_mismatch × Type mismatch. ╭─[entry #32:2:1] 2 │ let y = "aa" 3 │ a --x=$y · ─┬ · ╰── expected int, found string ╰──── ```
This commit is contained in:
@ -73,6 +73,14 @@ fn custom_switch1() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_flag_with_type_checking() -> TestResult {
|
||||
fail_test(
|
||||
r#"def florb [--dry-run: int] { $dry_run }; let y = "3"; florb --dry-run=$y"#,
|
||||
"type_mismatch",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_switch2() -> TestResult {
|
||||
run_test(
|
||||
@ -116,7 +124,7 @@ fn custom_flag1() -> TestResult {
|
||||
r#"def florb [
|
||||
--age: int = 0
|
||||
--name = "foobar"
|
||||
] {
|
||||
] {
|
||||
($age | into string) + $name
|
||||
}
|
||||
florb"#,
|
||||
|
Reference in New Issue
Block a user