Skip to content

Commit 13ac7fa

Browse files
authored
fix(grainfmt): Fix formatting of function types with a single tuple arg (#2230)
1 parent bdbbd05 commit 13ac7fa

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

compiler/src/formatting/fmt.re

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,18 @@ let print_type = (fmt, {ptyp_desc, ptyp_loc}) => {
26962696
)
26972697
++ break,
26982698
)
2699-
| PTyArrow([{ptyp_arg_label: Unlabeled} as param], return) =>
2699+
| PTyArrow(
2700+
[
2701+
{
2702+
ptyp_arg_label: Unlabeled,
2703+
ptyp_arg_type: {
2704+
ptyp_desc:
2705+
PTyAny | PTyVar(_) | PTyArrow(_, _) | PTyConstr(_, []),
2706+
},
2707+
} as param,
2708+
],
2709+
return,
2710+
) =>
27002711
fmt.print_parsed_type_argument(fmt, param)
27012712
++ string(" =>")
27022713
++ fmt.print_comment_range(

compiler/test/grainfmt/lambda.expected.gr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ y => {
99
let z = 2
1010
}
1111

12+
// Regression #2229
13+
let foo: ((a, b)) => Void = a => void
14+
1215
let testfna = forEachCodePoint(c => /* arg */ void)
1316

1417
let testfn = forEachCodePoint(c => /* arg */ {

compiler/test/grainfmt/lambda.input.gr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ y => {
77
let z = 2
88
}
99

10+
// Regression #2229
11+
let foo: ((a, b)) => Void = a => void
12+
1013
let testfna = forEachCodePoint(c /* arg */ => void)
1114

1215
let testfn = forEachCodePoint(c /* arg */ => {

0 commit comments

Comments
 (0)