From 6649da3f5d69c619e9e549b1927d4971130d44d4 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sun, 3 Apr 2022 10:41:36 +1200 Subject: [PATCH] Add support for single value row conditions (#5072) --- crates/nu-parser/src/parser.rs | 9 ++++++++- src/tests/test_parser.rs | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 7b3b33558..859d46419 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -3993,7 +3993,7 @@ pub fn parse_math_expression( let mut last_prec = 1000000; let mut error = None; - let (lhs, err) = parse_value( + let (mut lhs, err) = parse_value( working_set, spans[0], &SyntaxShape::Any, @@ -4002,6 +4002,13 @@ pub fn parse_math_expression( error = error.or(err); idx += 1; + if idx >= spans.len() { + // We already found the one part of our expression, so let's expand + if let Some(row_var_id) = lhs_row_var_id { + expand_to_cell_path(working_set, &mut lhs, row_var_id, expand_aliases_denylist); + } + } + expr_stack.push(lhs); while idx < spans.len() { diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index c457236f3..e98c61e1f 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -367,3 +367,11 @@ fn proper_rest_types() -> TestResult { "not verbose!", ) } + +#[test] +fn single_value_row_condition() -> TestResult { + run_test( + r#"[[a, b]; [true, false], [true, true]] | where a | length"#, + "2", + ) +}