diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 90aeb44ab3..567bc7ad3f 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -3838,7 +3838,7 @@ pub fn parse_signature_helper(working_set: &mut StateWorkingSet, span: Span) -> } } t => { - if t != &expression_ty { + if !type_compatible(t, &expression_ty) { working_set.error( ParseError::AssignmentMismatch( "Default value is the wrong type" diff --git a/tests/parsing/mod.rs b/tests/parsing/mod.rs index 105173c109..49aaedebda 100644 --- a/tests/parsing/mod.rs +++ b/tests/parsing/mod.rs @@ -247,6 +247,12 @@ fn parse_long_duration() { } #[rstest] +#[case("def test [ --a: any = 32 ] {}")] +#[case("def test [ --a: number = 32 ] {}")] +#[case("def test [ --a: number = 32.0 ] {}")] +#[case("def test [ --a: list = [ 1 2 3 ] ] {}")] +#[case("def test [ --a: record = { a: 32 b: 'qwe' c: 'wqe' } ] {}")] +#[case("def test [ --a: record = { a: 32 b: 'qwe'} ] {}")] #[case("def test []: int -> int { 1 }")] #[case("def test []: string -> string { 'qwe' }")] #[case("def test []: nothing -> nothing { null }")]