mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Fix as pattern formatting inside apply
This commit is contained in:
parent
f8b0be725c
commit
04612fb2cb
5 changed files with 48 additions and 1 deletions
|
@ -395,7 +395,7 @@ fn fmt_pattern_only(
|
|||
}
|
||||
|
||||
Pattern::As(pattern, pattern_as) => {
|
||||
let needs_parens = parens == Parens::InAsPattern;
|
||||
let needs_parens = parens == Parens::InAsPattern || parens == Parens::InApply;
|
||||
|
||||
if needs_parens {
|
||||
buf.indent(indent);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
when t is
|
||||
Ok ({} as d) -> S
|
|
@ -0,0 +1,42 @@
|
|||
@0-29 SpaceAfter(
|
||||
When(
|
||||
@5-6 Var {
|
||||
module_name: "",
|
||||
ident: "t",
|
||||
},
|
||||
[
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@14-25 SpaceBefore(
|
||||
Apply(
|
||||
@14-16 Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
@18-25 As(
|
||||
@18-20 RecordDestructure(
|
||||
[],
|
||||
),
|
||||
PatternAs {
|
||||
spaces_before: [],
|
||||
identifier: @24-25 "d",
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
value: @28-29 Tag(
|
||||
"S",
|
||||
),
|
||||
guard: None,
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
|
@ -0,0 +1,2 @@
|
|||
when t is
|
||||
Ok ({} as d)->S
|
|
@ -564,6 +564,7 @@ mod test_snapshots {
|
|||
pass/pattern_as_spaces.expr,
|
||||
pass/pattern_comma_newlines.expr,
|
||||
pass/pattern_record_apply_comment.expr,
|
||||
pass/pattern_with_as_parens.expr,
|
||||
pass/pattern_with_space_in_parens.expr, // https://github.com/roc-lang/roc/issues/929
|
||||
pass/pizza_dbg.expr,
|
||||
pass/pizza_question.moduledefs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue