Skip to content

Commit 91d5cdf

Browse files
marcusrobertsMarcus Roberts
andauthored
fix(grainfmt): Use only the correct comments for constraints (#1388)
Use only the correct comments for contraints Co-authored-by: Marcus Roberts <marcus@marcusr.com>
1 parent bdd4be4 commit 91d5cdf

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

compiler/src/formatting/format.re

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2982,7 +2982,15 @@ and print_expression =
29822982
),
29832983
Doc.text(":"),
29842984
Doc.space,
2985-
print_type(~original_source, ~comments, parsed_type),
2985+
print_type(
2986+
~original_source,
2987+
~comments=
2988+
Comment_utils.get_comments_inside_location(
2989+
~location=parsed_type.ptyp_loc,
2990+
comments,
2991+
),
2992+
parsed_type,
2993+
),
29862994
]),
29872995
);
29882996
| PExpLambda(patterns, expression) =>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import List from "list"
2+
let test = test => {
3+
// Comments
4+
List.forEach(i => {
5+
// Comment In ForEach
6+
print(i)
7+
}, test: List<Number>)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import List from "list"
2+
let test = test => {
3+
// Comments
4+
List.forEach(i => {
5+
// Comment In ForEach
6+
print(i)
7+
}, test: List<Number>)
8+
}

compiler/test/suites/formatter.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ describe("formatter", ({test, testSkip}) => {
4545
assertFormatOutput("parens", "parens");
4646
assertFormatOutput("windows", "windows");
4747
assertFormatOutput("patterns", "patterns");
48+
assertFormatOutput("constraints", "constraints");
4849
});

0 commit comments

Comments
 (0)