diff --git a/crates/nu-command/tests/commands/def.rs b/crates/nu-command/tests/commands/def.rs index 6ba6b6bfa0..ffa1493553 100644 --- a/crates/nu-command/tests/commands/def.rs +++ b/crates/nu-command/tests/commands/def.rs @@ -197,3 +197,15 @@ param: list = [one] assert!(actual.out.contains(r#"["one"]"#)); }) } + +#[test] +fn def_with_paren_params() { + let actual = nu!( + cwd: ".", pipeline( + r#" + def foo (x: int, y: int) { $x + $y }; foo 1 2 + "# + )); + + assert_eq!(actual.out, "3"); +} diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 889c8e7858..30de612f08 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1698,10 +1698,13 @@ pub(crate) fn parse_dollar_expr( pub fn parse_paren_expr( working_set: &mut StateWorkingSet, span: Span, + shape: &SyntaxShape, expand_aliases_denylist: &[usize], ) -> (Expression, Option) { if let (expr, None) = parse_range(working_set, span, expand_aliases_denylist) { (expr, None) + } else if matches!(shape, SyntaxShape::Signature) { + return parse_signature(working_set, span, expand_aliases_denylist); } else { parse_full_cell_path(working_set, None, span, expand_aliases_denylist) } @@ -4567,7 +4570,7 @@ pub fn parse_value( match bytes[0] { b'$' => return parse_dollar_expr(working_set, span, expand_aliases_denylist), - b'(' => return parse_paren_expr(working_set, span, expand_aliases_denylist), + b'(' => return parse_paren_expr(working_set, span, shape, expand_aliases_denylist), b'{' => return parse_brace_expr(working_set, span, shape, expand_aliases_denylist), b'[' => match shape { SyntaxShape::Any