diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 1aee66d786..c592b4e479 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -3695,7 +3695,7 @@ pub fn parse_signature_helper(working_set: &mut StateWorkingSet, span: Span) -> Arg::RestPositional(PositionalArg { shape, var_id, .. }) => { - working_set.set_variable_type(var_id.expect("internal error: all custom parameters must have var_ids"), syntax_shape.to_type()); + working_set.set_variable_type(var_id.expect("internal error: all custom parameters must have var_ids"), Type::List(Box::new(syntax_shape.to_type()))); *shape = syntax_shape; } Arg::Flag(Flag { arg, var_id, .. }) => { diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index 24ce15b001..7d0b678fd0 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -665,3 +665,11 @@ fn properly_nest_captures() -> TestResult { fn properly_nest_captures_call_first() -> TestResult { run_test(r#"do { let b = 3; c; def c [] { $b }; c }"#, "3") } + +#[test] +fn properly_typecheck_rest_param() -> TestResult { + run_test( + r#"def foo [...rest: string] { $rest | length }; foo "a" "b" "c""#, + "3", + ) +}