Skip to content

Commit

Permalink
fix(grainfmt): Correctly add space between arguments in enum pattern (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Sep 6, 2021
1 parent f15f37b commit 8c647fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/grainformat/reformat.re
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ and print_pattern =
if (List.length(patterns) > 0) {
add_parens(
Doc.join(
Doc.comma,
Doc.concat([Doc.comma, Doc.space]),
List.map(
pat => print_pattern(~pat, ~parent_loc, ~original_source),
patterns,
Expand Down
10 changes: 10 additions & 0 deletions compiler/test/formatter_inputs/matches.gr
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ export let pop = (queue) => {
{ forwards: [head, ...ftail], backwards } => { forwards: ftail, backwards }
}
}

enum Foo<a, b, c> { A(a, b), B(b, c) }

match (A(1, 2)) {
A(a,b) => true,
B(
b,
c
) => false
}
7 changes: 7 additions & 0 deletions compiler/test/formatter_outputs/matches.gr
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ export let pop = queue => {
{ forwards: [head, ...ftail], backwards } => { forwards: ftail, backwards },
}
}

enum Foo<a, b, c> { A(a, b), B(b, c) }

match (A(1, 2)) {
A(a, b) => true,
B(b, c) => false,
}

0 comments on commit 8c647fa

Please sign in to comment.