Skip to content

Commit f969df9

Browse files
authored
fix(grainfmt): Correct formatting of submodules ending with comments (#2288)
1 parent 17147cd commit f969df9

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

compiler/src/formatting/fmt.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,6 +3396,7 @@ let print_module_declaration = (fmt, {pmod_name, pmod_stmts, pmod_loc}) => {
33963396
prev =>
33973397
fmt.print_comment_range(
33983398
fmt,
3399+
~block_end=true,
33993400
~lead=space,
34003401
prev.ptop_loc,
34013402
enclosing_end_location(pmod_loc),

compiler/test/grainfmt/comments.expected.gr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,8 @@ let [/*foo */] = 5
660660
2
661661
1 /* abc */ /2
662662
1 /* abc */ / /* xyz */ 2
663+
664+
// Regression for #2287
665+
module Bar {
666+
1 // foo
667+
}

compiler/test/grainfmt/comments.input.gr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,9 @@ let [ /*foo */] = 5
508508
2
509509
1/* abc *//2
510510
1/* abc */ / /* xyz */2
511+
512+
513+
// Regression for #2287
514+
module Bar {
515+
1 // foo
516+
}

0 commit comments

Comments
 (0)