mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Relax implements handling in patterns
This commit is contained in:
parent
d6d396b887
commit
4a19926425
5 changed files with 62 additions and 6 deletions
|
@ -155,11 +155,7 @@ fn fmt_pattern_only(
|
|||
match me {
|
||||
Pattern::Identifier { ident } => {
|
||||
buf.indent(indent);
|
||||
if *ident == "implements" {
|
||||
buf.push_str("(implements)");
|
||||
} else {
|
||||
snakify_camel_ident(buf, ident);
|
||||
}
|
||||
snakify_camel_ident(buf, ident);
|
||||
}
|
||||
Pattern::Tag(name) | Pattern::OpaqueRef(name) => {
|
||||
buf.indent(indent);
|
||||
|
@ -520,7 +516,16 @@ pub fn pattern_fmt_apply(
|
|||
buf.ensure_ends_with_newline();
|
||||
}
|
||||
|
||||
fmt_pattern_only(&arg.item, buf, parens, indent_more, arg.item.is_multiline());
|
||||
if matches!(
|
||||
arg.item,
|
||||
Pattern::Identifier {
|
||||
ident: "implements"
|
||||
}
|
||||
) {
|
||||
buf.push_str("(implements)");
|
||||
} else {
|
||||
fmt_pattern_only(&arg.item, buf, parens, indent_more, arg.item.is_multiline());
|
||||
}
|
||||
|
||||
last_after = arg.after;
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
{ implements } = d
|
||||
I
|
|
@ -0,0 +1,46 @@
|
|||
@0-16 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-14,
|
||||
],
|
||||
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-12 RecordDestructure(
|
||||
[
|
||||
@1-11 Identifier {
|
||||
ident: "implements",
|
||||
},
|
||||
],
|
||||
),
|
||||
@13-14 Var {
|
||||
module_name: "",
|
||||
ident: "d",
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
@15-16 SpaceBefore(
|
||||
Tag(
|
||||
"I",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
|
@ -0,0 +1,2 @@
|
|||
{implements}=d
|
||||
I
|
|
@ -442,6 +442,7 @@ mod test_snapshots {
|
|||
pass/implements_newline_in_fn_ty.expr,
|
||||
pass/implements_newlines_comments.expr,
|
||||
pass/implements_not_keyword.expr,
|
||||
pass/implements_record_destructure.expr,
|
||||
pass/import.moduledefs,
|
||||
pass/import_from_package.moduledefs,
|
||||
pass/import_in_closure_with_curlies_after.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue