From 3ef5e90b6429368e4ecfe8aafac36a7539ab6e7b Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 28 Jul 2023 06:26:28 +1200 Subject: [PATCH] Fix the implied collect type to 'any' (#9827) # Description Previously, we had a bug slip in about implied collection caused by `$in`, that this output type would be of type `string`. The type system fixes in 0.83 now make this more visible and cause issues. This PR changes the output of the implied collection to `any`. At some point in the future, we may want to carry the type through where we can, but `any` should unblock using `$in`. fixes #9825 # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-parser/src/parser.rs | 2 +- src/tests/test_parser.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index c592b4e47..4f8159b97 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -6176,7 +6176,7 @@ fn wrap_expr_with_collect(working_set: &mut StateWorkingSet, expr: &Expression) parser_info: HashMap::new(), })), span, - ty: Type::String, + ty: Type::Any, custom_completion: None, } } else { diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index 7d0b678fd..65cf35d38 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -673,3 +673,8 @@ fn properly_typecheck_rest_param() -> TestResult { "3", ) } + +#[test] +fn implied_collect_has_compatible_type() -> TestResult { + run_test(r#"let idx = 3 | $in; $idx < 1"#, "false") +}