diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 3416e538df..0f72132d10 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -486,7 +486,7 @@ fn parse_short_flags( && matches!( sig.get_positional(positional_idx), Some(PositionalArg { - shape: SyntaxShape::Int | SyntaxShape::Number, + shape: SyntaxShape::Int | SyntaxShape::Number | SyntaxShape::Float, .. }) ) diff --git a/tests/repl/test_custom_commands.rs b/tests/repl/test_custom_commands.rs index 43a24fa250..1f36b0e90c 100644 --- a/tests/repl/test_custom_commands.rs +++ b/tests/repl/test_custom_commands.rs @@ -274,3 +274,9 @@ fn dont_allow_implicit_casting_between_glob_and_string() -> TestResult { "can't convert", ) } + +#[test] +fn allow_pass_negative_float() -> TestResult { + run_test("def spam [val: float] { $val }; spam -1.4", "-1.4")?; + run_test("def spam [val: float] { $val }; spam -2", "-2") +}