Fix as in apply type

This commit is contained in:
Joshua Warner 2024-12-18 10:35:18 -08:00
parent bab5e65480
commit 7ba5135602
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 69 additions and 2 deletions

View file

@ -367,13 +367,13 @@ fn fmt_ty_ann(
}
TypeAnnotation::As(lhs, spaces, TypeHeader { name, vars }) => {
let write_parens = parens == Parens::InAsPattern;
let write_parens = parens == Parens::InAsPattern || parens == Parens::InApply;
buf.indent(indent);
if write_parens {
buf.push('(')
}
buf.indent(indent);
let lhs_indent = buf.cur_line_indent();
lhs.value
.format_with_options(buf, Parens::InAsPattern, Newlines::No, indent);

View file

@ -0,0 +1,62 @@
@0-16 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(0),
],
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: [
Alias {
header: TypeHeader {
name: @0-1 "N",
vars: [],
},
ann: @2-14 Apply(
"",
"A",
[
@5-0 As(
@5-6 Apply(
"",
"H",
[],
),
[],
TypeHeader {
name: @10-11 "H",
vars: [],
},
),
@13-14 Apply(
"",
"H",
[],
),
],
),
},
],
value_defs: [],
},
@15-16 SpaceBefore(
Tag(
"I",
),
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,2 @@
N:A((H)as H) H
I

View file

@ -436,6 +436,7 @@ mod test_snapshots {
pass/function_with_tuple_ext_type.expr,
pass/function_with_tuple_type.expr,
pass/h_greater_comment_minus_div.expr,
pass/h_parens_as_parens_h_ann.expr,
pass/highest_float.expr,
pass/highest_int.expr,
pass/i_over_not_g.expr,