lift to spaces in ann_lift_to_node default case

This commit is contained in:
Joshua Warner 2024-12-12 22:13:41 -08:00
parent d3426ebce1
commit f233c5328d
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 79 additions and 6 deletions

View file

@ -427,7 +427,6 @@ fn lower<'a, 'b: 'a>(
fn fmt_ty_collection(
buf: &mut Buf<'_>,
indent: u16,
braces: Braces,
items: Collection<'_, Loc<TypeAnnotation<'_>>>,
@ -1215,11 +1214,14 @@ fn ann_lift_to_node<'a, 'b: 'a>(
inner
}
}
_ => Spaces {
before: &[],
item: Node::TypeAnnotation(*ann),
after: &[],
},
_ => {
let lifted = ann_lift_spaces(arena, ann);
Spaces {
before: lifted.before,
item: Node::TypeAnnotation(lifted.item),
after: lifted.after,
}
}
}
}

View file

@ -0,0 +1,63 @@
@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 NumLiteral(
"1",
),
@2-14 Tuple {
elems: [
@3-10 Tuple {
elems: [],
ext: Some(
@6-7 SpaceAfter(
BoundVariable(
"n",
),
[
LineComment(
"",
),
],
),
),
},
],
ext: Some(
@12-13 BoundVariable(
"n",
),
),
},
),
],
},
@15-16 SpaceBefore(
Var {
module_name: "",
ident: "l",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,3 @@
1:(()(n#
))(n)
l

View file

@ -301,6 +301,7 @@ mod test_snapshots {
pass/annotation_tuple_comment.expr,
pass/annotation_tuple_newline.expr,
pass/annotation_tuple_parens_newlines.expr,
pass/annotation_tuples_ext_galore.expr,
pass/applies_in_binop.expr,
pass/apply_binop_switch.expr,
pass/apply_closure_pizza.expr,