From 9448225690e0a3161adb151555304af34db9d885 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sat, 29 Jul 2023 06:23:17 +1200 Subject: [PATCH] Fix transpose input/output types (#9842) # Description As the typechecker doesn't currently support having the same input type but two different output types, collapse the `transpose` input/output signatures for now so that we don't mistakenly think that when given a `table` a `table is always returned. fixes https://github.com/nushell/nushell/issues/9710 # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/filters/transpose.rs | 3 +-- src/tests/test_type_check.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/nu-command/src/filters/transpose.rs b/crates/nu-command/src/filters/transpose.rs index ede1b1c942..326acd8ae6 100644 --- a/crates/nu-command/src/filters/transpose.rs +++ b/crates/nu-command/src/filters/transpose.rs @@ -27,8 +27,7 @@ impl Command for Transpose { fn signature(&self) -> Signature { Signature::build("transpose") .input_output_types(vec![ - (Type::Table(vec![]), Type::Table(vec![])), - (Type::Table(vec![]), Type::Record(vec![])), + (Type::Table(vec![]), Type::Any), (Type::Record(vec![]), Type::Table(vec![])), ]) .switch( diff --git a/src/tests/test_type_check.rs b/src/tests/test_type_check.rs index 62194bf146..cc7da49ce3 100644 --- a/src/tests/test_type_check.rs +++ b/src/tests/test_type_check.rs @@ -86,3 +86,11 @@ fn record_subtyping_3() -> TestResult { "expected", ) } + +#[test] +fn transpose_into_load_env() -> TestResult { + run_test( + "[[col1, col2]; [a, 10], [b, 20]] | transpose -i -r -d | load-env; $env.a", + "10", + ) +}