Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643
- Rewatch: Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
- Rewatch: Use root package suffix in clean log messages. https://github.com/rescript-lang/rescript/pull/7648
- Fix inside comment printing for empty dict. https://github.com/rescript-lang/rescript/pull/7654

# 12.0.0-beta.1

Expand Down
7 changes: 4 additions & 3 deletions compiler/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ and print_literal_dict_expr ~state (e : Parsetree.expression) cmt_tbl =
Doc.indent
(Doc.concat
[
Doc.soft_line;
(if rows = [] then Doc.nil else Doc.soft_line);
Doc.join
~sep:(Doc.concat [Doc.text ","; Doc.line])
(List.map
Expand All @@ -1523,8 +1523,8 @@ and print_literal_dict_expr ~state (e : Parsetree.expression) cmt_tbl =
print_comments doc cmt_tbl e.pexp_loc)
rows);
]);
Doc.trailing_comma;
Doc.soft_line;
(if rows = [] then Doc.nil
else Doc.concat [Doc.trailing_comma; Doc.soft_line]);
])

and print_constructor_declarations ~state ~private_flag
Expand Down Expand Up @@ -4225,6 +4225,7 @@ and print_pexp_apply ~state expr cmt_tbl =
Doc.concat
[
Doc.text "dict{";
print_comments_inside cmt_tbl expr.pexp_loc;
print_literal_dict_expr ~state key_values cmt_tbl;
Doc.rbrace;
]
Expand Down
6 changes: 6 additions & 0 deletions tests/syntax_tests/data/printer/expr/dict.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// empty dict
let x = dict{}

// empty dict with inside comment
let x = dict{
// inside comment

}

// one value
let x = dict{"foo": "bar"}

Expand Down
5 changes: 5 additions & 0 deletions tests/syntax_tests/data/printer/expr/expected/dict.res.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// empty dict
let x = dict{}

// empty dict with inside comment
let x = dict{
// inside comment
}

// one value
let x = dict{"foo": "bar"}

Expand Down