Skip to content

Commit

Permalink
Fix comment removed when function signature has type keyword (#6997)
Browse files Browse the repository at this point in the history
* Fix comment removed when function signature has type keyword

* Update CHANGELOG
  • Loading branch information
shulhi authored Sep 1, 2024
1 parent d241c65 commit f5ca410
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fix incorrect incorrect printing of module binding with signature. https://github.com/rescript-lang/rescript-compiler/pull/6963
- Fix incorrect printing of external with `@as` attribute and `_` placholder (fixed argument). https://github.com/rescript-lang/rescript-compiler/pull/6970
- Disallow spreading anything but regular variants inside of other variants. https://github.com/rescript-lang/rescript-compiler/pull/6980
- Fix comment removed when function signature has `type` keyword. https://github.com/rescript-lang/rescript-compiler/pull/6997

#### :house: Internal

Expand Down Expand Up @@ -2614,4 +2615,4 @@ Features:
# 1.0.0
Initial release
Initial release
2 changes: 2 additions & 0 deletions jscomp/syntax/src/res_comments_table.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,8 @@ and walk_expression expr t comments =
attach t.leading expr.pexp_loc leading;
walk_expression expr t inside;
attach t.trailing expr.pexp_loc trailing
| Pexp_construct ({txt = Longident.Lident "Function$"}, Some return_expr) ->
walk_expression return_expr t comments
| _ ->
if is_block_expr return_expr then walk_expression return_expr t comments
else
Expand Down
4 changes: 2 additions & 2 deletions jscomp/syntax/tests/printer/comments/expected/expr.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ let f = (
/* c6 */ ~x=?,
) => /* c7 */ ()

let multiply = (type /* c-2 */ t /* c-1 */, m1 /* c1 */, /* c2 */ m2 /* c3 */) => ()
let multiply = (type /* c-2 */ t /* c-1 */, /* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => ()
let multiply = (
type /* c-4 */ t /* c-3 */,
m1 /* c1 */,
/* c0 */ m1 /* c1 */,
type /* c-2 */ s /* c-1 */,
/* c2 */ m2 /* c3 */,
) => ()
Expand Down

0 comments on commit f5ca410

Please sign in to comment.