From 5832823dff8e7286c15d011c7a121921eb277f65 Mon Sep 17 00:00:00 2001 From: zc he Date: Fri, 21 Mar 2025 19:35:18 +0800 Subject: [PATCH] fix: flatten of empty closures (#15374) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #15373 # Description Now `ast -f "{||}"` will return ``` ╭─content─┬─────shape─────┬─────span──────╮ │ {||} │ shape_closure │ ╭───────┬───╮ │ │ │ │ │ start │ 0 │ │ │ │ │ │ end │ 4 │ │ │ │ │ ╰───────┴───╯ │ ╰─────────┴───────────────┴───────────────╯ ``` Similar to those of `ast -f "[]"`/`ast -f "{}"` # User-Facing Changes # Tests + Formatting I didn't find the right place to do the test, except for the examples of `ast` command. # After Submitting --- crates/nu-parser/src/flatten.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/nu-parser/src/flatten.rs b/crates/nu-parser/src/flatten.rs index 46cf901f9a..c49b1720df 100644 --- a/crates/nu-parser/src/flatten.rs +++ b/crates/nu-parser/src/flatten.rs @@ -232,7 +232,8 @@ fn flatten_expression_into( None } } else { - None + // for empty closures + Some((outer_span, FlatShape::Closure)) }; output.extend(flattened);