mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-02 13:58:50 +00:00
Fix double-as formatting
This commit is contained in:
parent
307b0d9ea9
commit
54a0456c30
5 changed files with 72 additions and 1 deletions
|
|
@ -359,8 +359,14 @@ fn fmt_ty_ann(
|
|||
}
|
||||
|
||||
TypeAnnotation::As(lhs, spaces, TypeHeader { name, vars }) => {
|
||||
let write_parens = parens == Parens::InAsPattern;
|
||||
|
||||
if write_parens {
|
||||
buf.push('(')
|
||||
}
|
||||
|
||||
lhs.value
|
||||
.format_with_options(buf, Parens::InFunctionType, Newlines::No, indent);
|
||||
.format_with_options(buf, Parens::InAsPattern, Newlines::No, indent);
|
||||
buf.spaces(1);
|
||||
format_spaces(buf, spaces, newlines, indent);
|
||||
buf.indent(indent);
|
||||
|
|
@ -372,6 +378,10 @@ fn fmt_ty_ann(
|
|||
var.value
|
||||
.format_with_options(buf, Parens::NotNeeded, Newlines::No, indent);
|
||||
}
|
||||
|
||||
if write_parens {
|
||||
buf.push(')')
|
||||
}
|
||||
}
|
||||
|
||||
TypeAnnotation::Where(annot, implements_clauses) => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
s : (e as A) as A
|
||||
s
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
@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: [
|
||||
Annotation(
|
||||
@0-1 Identifier {
|
||||
ident: "s",
|
||||
},
|
||||
@3-0 As(
|
||||
@3-0 As(
|
||||
@3-4 BoundVariable(
|
||||
"e",
|
||||
),
|
||||
[],
|
||||
TypeHeader {
|
||||
name: @8-9 "A",
|
||||
vars: [],
|
||||
},
|
||||
),
|
||||
[],
|
||||
TypeHeader {
|
||||
name: @13-14 "A",
|
||||
vars: [],
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@15-16 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
s:(e as A)as A
|
||||
s
|
||||
|
|
@ -299,6 +299,7 @@ mod test_snapshots {
|
|||
pass/annotated_tuple_destructure.expr,
|
||||
pass/annotation_apply_newlines.expr,
|
||||
pass/annotation_comment_before_colon.expr,
|
||||
pass/annotation_double_as.expr,
|
||||
pass/annotation_tag_parens_comment.expr,
|
||||
pass/annotation_tuple_comment.expr,
|
||||
pass/annotation_tuple_newline.expr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue