mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Don't do empty record destructure elision when the body is itself Defs
This commit is contained in:
parent
cabe67f88d
commit
89a64fed74
5 changed files with 83 additions and 0 deletions
|
@ -1039,6 +1039,7 @@ pub fn fmt_body<'a>(
|
||||||
&& collection.is_empty()
|
&& collection.is_empty()
|
||||||
&& pattern_extracted.before.iter().all(|s| s.is_newline())
|
&& pattern_extracted.before.iter().all(|s| s.is_newline())
|
||||||
&& pattern_extracted.after.iter().all(|s| s.is_newline())
|
&& pattern_extracted.after.iter().all(|s| s.is_newline())
|
||||||
|
&& !matches!(body.extract_spaces().item, Expr::Defs(..))
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{} =
|
||||||
|
p
|
||||||
|
t
|
||||||
|
J
|
|
@ -0,0 +1,73 @@
|
||||||
|
Defs(
|
||||||
|
Defs {
|
||||||
|
tags: [
|
||||||
|
EitherIndex(2147483648),
|
||||||
|
],
|
||||||
|
regions: [
|
||||||
|
@0-9,
|
||||||
|
],
|
||||||
|
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: [],
|
||||||
|
value_defs: [
|
||||||
|
Body(
|
||||||
|
@0-2 RecordDestructure(
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
@5-9 SpaceBefore(
|
||||||
|
Defs(
|
||||||
|
Defs {
|
||||||
|
tags: [
|
||||||
|
EitherIndex(2147483648),
|
||||||
|
],
|
||||||
|
regions: [
|
||||||
|
@5-6,
|
||||||
|
],
|
||||||
|
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: [],
|
||||||
|
value_defs: [
|
||||||
|
Stmt(
|
||||||
|
@5-6 Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "p",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
@8-9 SpaceBefore(
|
||||||
|
Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "t",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
@10-11 SpaceBefore(
|
||||||
|
Tag(
|
||||||
|
"J",
|
||||||
|
),
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
|
@ -0,0 +1,4 @@
|
||||||
|
{}=
|
||||||
|
p
|
||||||
|
t
|
||||||
|
J
|
|
@ -604,6 +604,7 @@ mod test_snapshots {
|
||||||
pass/spaces_inside_empty_list.expr,
|
pass/spaces_inside_empty_list.expr,
|
||||||
pass/standalone_module_defs.moduledefs,
|
pass/standalone_module_defs.moduledefs,
|
||||||
pass/stmt_parens_minus.expr,
|
pass/stmt_parens_minus.expr,
|
||||||
|
pass/stmts_in_empty_record_assignment.expr,
|
||||||
pass/str_block_multiple_newlines.expr,
|
pass/str_block_multiple_newlines.expr,
|
||||||
pass/string_without_escape.expr,
|
pass/string_without_escape.expr,
|
||||||
pass/sub_var_with_spaces.expr,
|
pass/sub_var_with_spaces.expr,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue