New Lambda Syntax with |...|

This adds parser support for the new lambda syntax.  It does not remove
the existing syntax, nor will the new syntax be retained in formatting.
That will be done in a separate PR to keep the two respective PRs
relatively small and easy to review.
This commit is contained in:
Anthony Bullard 2025-01-15 05:50:34 -06:00
parent 4e66910ef8
commit 8e1e1520e3
No known key found for this signature in database
6 changed files with 172 additions and 50 deletions

View file

@ -1778,41 +1778,80 @@ mod test_fmt {
#[test]
fn lambda_returns_record_new_syntax() {
expr_formats_same(indoc!(
r"
to_record = |_| {
x: 1,
y: 2,
z: 3,
}
to_record
"
));
expr_formats_same(indoc!(
r"
func = |_|
{ x: 1, y: 2, z: 3 }
func
"
));
expr_formats_same(indoc!(
r"
to_record = |_|
val = 0
{
expr_formats_to(
indoc!(
r"
to_record = |_| {
x: 1,
y: 2,
z: 3,
}
to_record
"
));
to_record
"
),
indoc!(
r"
to_record = \_ -> {
x: 1,
y: 2,
z: 3,
}
to_record
"
),
);
expr_formats_to(
indoc!(
r"
func = |_|
{ x: 1, y: 2, z: 3 }
func
"
),
indoc!(
r"
func = \_ ->
{ x: 1, y: 2, z: 3 }
func
"
),
);
expr_formats_to(
indoc!(
r"
to_record = |_|
val = 0
{
x: 1,
y: 2,
z: 3,
}
to_record
"
),
indoc!(
r"
to_record = \_ ->
val = 0
{
x: 1,
y: 2,
z: 3,
}
to_record
"
),
);
expr_formats_to(
indoc!(
@ -1829,7 +1868,7 @@ mod test_fmt {
),
indoc!(
r"
to_record = |_| {
to_record = \_ -> {
x: 1,
y: 2,
z: 3,