Skip to content

Commit e4ccfec

Browse files
committed
Print comments inside fn with no arg
1 parent 4bfe542 commit e4ccfec

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

compiler/syntax/src/res_printer.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,9 +4842,22 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
48424842
and print_arguments ~state ?(partial = false)
48434843
(args : (Asttypes.arg_label * Parsetree.expression) list) cmt_tbl =
48444844
match args with
4845-
| [(Nolabel, {pexp_desc = Pexp_construct ({txt = Longident.Lident "()"}, _)})]
4846-
->
4847-
Doc.text "()"
4845+
| [
4846+
( Nolabel,
4847+
{
4848+
pexp_desc = Pexp_construct ({txt = Longident.Lident "()"}, _);
4849+
pexp_loc = loc;
4850+
} );
4851+
] ->
4852+
if has_leading_line_comment cmt_tbl loc then
4853+
let cmt = print_comments Doc.nil cmt_tbl loc in
4854+
Doc.concat
4855+
[
4856+
Doc.lparen;
4857+
Doc.indent (Doc.group (Doc.concat [Doc.soft_line; cmt]));
4858+
Doc.rparen;
4859+
]
4860+
else Doc.text "()"
48484861
| [(Nolabel, arg)] when ParsetreeViewer.is_huggable_expression arg ->
48494862
let arg_doc =
48504863
let doc = print_expression_with_comments ~state arg cmt_tbl in

0 commit comments

Comments
 (0)