fix: flatten of empty closures (#15374)

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
This commit is contained in:
zc he 2025-03-21 19:35:18 +08:00 committed by GitHub
parent 3fe355c4a6
commit 5832823dff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -232,7 +232,8 @@ fn flatten_expression_into(
None
}
} else {
None
// for empty closures
Some((outer_span, FlatShape::Closure))
};
output.extend(flattened);