Skip to content

Commit f5ca410

Browse files
authored
Fix comment removed when function signature has type keyword (#6997)
* Fix comment removed when function signature has type keyword * Update CHANGELOG
1 parent d241c65 commit f5ca410

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- Fix incorrect incorrect printing of module binding with signature. https://github.com/rescript-lang/rescript-compiler/pull/6963
3737
- Fix incorrect printing of external with `@as` attribute and `_` placholder (fixed argument). https://github.com/rescript-lang/rescript-compiler/pull/6970
3838
- Disallow spreading anything but regular variants inside of other variants. https://github.com/rescript-lang/rescript-compiler/pull/6980
39+
- Fix comment removed when function signature has `type` keyword. https://github.com/rescript-lang/rescript-compiler/pull/6997
3940

4041
#### :house: Internal
4142

@@ -2614,4 +2615,4 @@ Features:
26142615
26152616
# 1.0.0
26162617
2617-
Initial release
2618+
Initial release

jscomp/syntax/src/res_comments_table.ml

+2
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,8 @@ and walk_expression expr t comments =
14521452
attach t.leading expr.pexp_loc leading;
14531453
walk_expression expr t inside;
14541454
attach t.trailing expr.pexp_loc trailing
1455+
| Pexp_construct ({txt = Longident.Lident "Function$"}, Some return_expr) ->
1456+
walk_expression return_expr t comments
14551457
| _ ->
14561458
if is_block_expr return_expr then walk_expression return_expr t comments
14571459
else

jscomp/syntax/tests/printer/comments/expected/expr.res.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ let f = (
226226
/* c6 */ ~x=?,
227227
) => /* c7 */ ()
228228

229-
let multiply = (type /* c-2 */ t /* c-1 */, m1 /* c1 */, /* c2 */ m2 /* c3 */) => ()
229+
let multiply = (type /* c-2 */ t /* c-1 */, /* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => ()
230230
let multiply = (
231231
type /* c-4 */ t /* c-3 */,
232-
m1 /* c1 */,
232+
/* c0 */ m1 /* c1 */,
233233
type /* c-2 */ s /* c-1 */,
234234
/* c2 */ m2 /* c3 */,
235235
) => ()

0 commit comments

Comments
 (0)