Fix closure indentation and indented-else handling in niche pattern case

This commit is contained in:
Joshua Warner 2024-12-14 17:50:06 -08:00
parent 9f3f99c573
commit 307b0d9ea9
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
11 changed files with 299 additions and 128 deletions

View file

@ -0,0 +1,57 @@
@0-18 SpaceAfter(
Closure(
[
@1-13 Apply(
@1-2 Tag(
"I",
),
[
@2-10 RecordDestructure(
[
@3-9 OptionalField(
"p",
@5-9 Apply(
@5-6 Tag(
"Y",
),
[
@8-9 SpaceBefore(
Tag(
"Y",
),
[
Newline,
],
),
],
Space,
),
),
],
),
@10-13 List(
Collection {
items: [],
final_comments: [
Newline,
],
},
),
],
),
],
@17-18 SpaceBefore(
Tag(
"K",
),
[
Newline,
],
),
),
[
LineComment(
"(",
),
],
)

View file

@ -0,0 +1,8 @@
O { p ? if
a
then
A
else
&m } #
: e
i

View file

@ -0,0 +1,95 @@
@0-29 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(0),
],
regions: [
@0-27,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [
Alias {
header: TypeHeader {
name: @0-1 "O",
vars: [
@1-23 SpaceAfter(
RecordDestructure(
[
@2-22 OptionalField(
"p",
@4-22 If {
if_thens: [
(
@7-8 SpaceBefore(
SpaceAfter(
Var {
module_name: "",
ident: "a",
},
[
Newline,
],
),
[
Newline,
],
),
@14-15 SpaceBefore(
SpaceAfter(
Tag(
"A",
),
[
Newline,
],
),
[
Newline,
],
),
),
],
final_else: @20-22 RecordUpdater(
"m",
),
indented_else: false,
},
),
],
),
[
LineComment(
"",
),
],
),
],
},
ann: @26-27 BoundVariable(
"e",
),
},
],
value_defs: [],
},
@28-29 SpaceBefore(
Var {
module_name: "",
ident: "i",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,7 @@
O{p?if
a
then
A
else&m}#
:e
i

View file

@ -340,6 +340,7 @@ mod test_snapshots {
pass/call_bang.expr,
pass/call_bang_no_space.expr,
pass/capture_body_parens_comment.expr,
pass/closure_complex_pattern_indent_issue.expr,
pass/closure_in_apply_in_binop.expr,
pass/closure_in_binop_with_spaces.expr,
pass/closure_pat_reccord_comment.expr,
@ -427,6 +428,7 @@ mod test_snapshots {
pass/highest_int.expr,
pass/i_over_not_g.expr,
pass/if_def.expr,
pass/if_in_record_field_opt_pat.expr,
pass/if_newline_then_negate_else_recordupdater.expr,
pass/implements_newline_in_fn_ty.expr,
pass/implements_newlines_comments.expr,