Skip to content

Commit

Permalink
fix(grainfmt): Fix formatting of function types with a single tuple a…
Browse files Browse the repository at this point in the history
…rg (#2230)
  • Loading branch information
spotandjake authored Jan 17, 2025
1 parent bdbbd05 commit 13ac7fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion compiler/src/formatting/fmt.re
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,18 @@ let print_type = (fmt, {ptyp_desc, ptyp_loc}) => {
)
++ break,
)
| PTyArrow([{ptyp_arg_label: Unlabeled} as param], return) =>
| PTyArrow(
[
{
ptyp_arg_label: Unlabeled,
ptyp_arg_type: {
ptyp_desc:
PTyAny | PTyVar(_) | PTyArrow(_, _) | PTyConstr(_, []),
},
} as param,
],
return,
) =>
fmt.print_parsed_type_argument(fmt, param)
++ string(" =>")
++ fmt.print_comment_range(
Expand Down
3 changes: 3 additions & 0 deletions compiler/test/grainfmt/lambda.expected.gr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ y => {
let z = 2
}

// Regression #2229
let foo: ((a, b)) => Void = a => void

let testfna = forEachCodePoint(c => /* arg */ void)

let testfn = forEachCodePoint(c => /* arg */ {
Expand Down
3 changes: 3 additions & 0 deletions compiler/test/grainfmt/lambda.input.gr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ y => {
let z = 2
}

// Regression #2229
let foo: ((a, b)) => Void = a => void

let testfna = forEachCodePoint(c /* arg */ => void)

let testfn = forEachCodePoint(c /* arg */ => {
Expand Down

0 comments on commit 13ac7fa

Please sign in to comment.