Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #2457 #7361

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion crates/compiler/parse/src/type_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,10 @@ fn expression<'a>(
.parse(arena, state, min_indent)?;

let (p2, rest, rest_state) = zero_or_more(skip_first(
backtrackable(byte(b',', EType::TFunctionArgument)),
backtrackable(skip_first(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing skip_first, I think we need to be preserving this space in the tree. Otherwise we could accidentally lose a comment when formatting, for example.

Rather than separately tracking spaces before/after the comma, we should probably just merge them. There's a handy merge_spaces function for just that purpose.

backtrackable(space0_e(EType::TIndentStart)),
byte(b',', EType::TFunctionArgument),
)),
one_of![
map_with_arena(
and(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
1 : (
f,
(ww -> p),
)e
1 : (f, ww -> p)e
Mh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@
),
@2-13 Tuple {
elems: [
@3-4 SpaceAfter(
BoundVariable(
"f",
),
[
Newline,
],
),
@6-11 Function(
@3-11 Function(
[
@3-4 BoundVariable(
"f",
),
@6-8 BoundVariable(
"ww",
),
Expand Down
Loading