diff --git a/crates/nu-cmd-lang/src/core_commands/let_.rs b/crates/nu-cmd-lang/src/core_commands/let_.rs index cd6ae2338e..649035c8dd 100644 --- a/crates/nu-cmd-lang/src/core_commands/let_.rs +++ b/crates/nu-cmd-lang/src/core_commands/let_.rs @@ -17,7 +17,7 @@ impl Command for Let { fn signature(&self) -> nu_protocol::Signature { Signature::build("let") - .input_output_types(vec![(Type::Nothing, Type::Nothing)]) + .input_output_types(vec![(Type::Any, Type::Nothing)]) .allow_variants_without_examples(true) .required("var_name", SyntaxShape::VarWithOptType, "variable name") .required( diff --git a/crates/nu-cmd-lang/src/core_commands/mut_.rs b/crates/nu-cmd-lang/src/core_commands/mut_.rs index 3a93d85bb7..35e54c43c4 100644 --- a/crates/nu-cmd-lang/src/core_commands/mut_.rs +++ b/crates/nu-cmd-lang/src/core_commands/mut_.rs @@ -17,7 +17,7 @@ impl Command for Mut { fn signature(&self) -> nu_protocol::Signature { Signature::build("mut") - .input_output_types(vec![(Type::Nothing, Type::Nothing)]) + .input_output_types(vec![(Type::Any, Type::Nothing)]) .allow_variants_without_examples(true) .required("var_name", SyntaxShape::VarWithOptType, "variable name") .required( diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index b4242a9779..6aec8c8517 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -623,3 +623,35 @@ fn def_with_input_output_broken_1() -> TestResult { fn def_with_input_output_broken_2() -> TestResult { fail_test(r#"def foo []: int -> { 3 }"#, "expected type") } + +#[test] +fn def_with_in_var_let_1() -> TestResult { + run_test( + r#"def foo []: [int -> int, string -> int] { let x = $in; if ($x | describe) == "int" { 3 } else { 4 } }; "100" | foo"#, + "4", + ) +} + +#[test] +fn def_with_in_var_let_2() -> TestResult { + run_test( + r#"def foo []: [int -> int, string -> int] { let x = $in; if ($x | describe) == "int" { 3 } else { 4 } }; 100 | foo"#, + "3", + ) +} + +#[test] +fn def_with_in_var_mut_1() -> TestResult { + run_test( + r#"def foo []: [int -> int, string -> int] { mut x = $in; if ($x | describe) == "int" { 3 } else { 4 } }; "100" | foo"#, + "4", + ) +} + +#[test] +fn def_with_in_var_mut_2() -> TestResult { + run_test( + r#"def foo []: [int -> int, string -> int] { mut x = $in; if ($x | describe) == "int" { 3 } else { 4 } }; 100 | foo"#, + "3", + ) +}