Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Un-indent comment after fun #2592

Merged
merged 4 commits into from
Oct 25, 2024
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 CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ profile. This started with version 0.26.0.
- \* Undo let-bindings normalizations (#2523, @gpetiot)
- \* Undo method parameters normalizations (#2529, @gpetiot)
- \* The `break-colon` option is now taken into account for method type constraints (#2529, @gpetiot)
- Improve indentation of comments after a `fun` (#2592, @Julow)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ and fmt_function ?(last_arg = false) ?force_closing_paren ~ctx ~ctx0
body ~pro $ cls_paren
in
let box k = if should_box then box k else k in
box (disambiguate_parens_wrap body $ Cmts.fmt_after c loc)
box (disambiguate_parens_wrap body) $ Cmts.fmt_after c loc

and fmt_label_arg ?(box = true) ?eol c (lbl, ({ast= arg; _} as xarg)) =
match (lbl, arg.pexp_desc) with
Expand Down
8 changes: 8 additions & 0 deletions test/passing/tests/js_source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8233,3 +8233,11 @@ let exists t key =

let _ = if x then 42 (* dummy *) else y
let _ = if x then 42 (* dummy *) else if y then z else w

let _ =
if x
then
fun _ -> true
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
else f
;;
8 changes: 8 additions & 0 deletions test/passing/tests/js_source.ml.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -10522,3 +10522,11 @@ let exists t key =

let _ = if x then 42 (* dummy *) else y
let _ = if x then 42 (* dummy *) else if y then z else w

let _ =
if x
then
fun _ -> true
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
else f
;;
10 changes: 9 additions & 1 deletion test/passing/tests/js_source.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ let ty_list : type a e. (a, e) ty -> (a vlist, e) ty =
| Thd, Noarg -> `Nil
| Ttl Thd, v -> `Cons v
: (noarg -> a * a vlist -> unit, c) ty_sel * c -> a vlist))
(* One can also write the type annotation directly *)
(* One can also write the type annotation directly *)
})
;;

Expand Down Expand Up @@ -10522,3 +10522,11 @@ let exists t key =

let _ = if x then 42 (* dummy *) else y
let _ = if x then 42 (* dummy *) else if y then z else w

let _ =
if x
then
fun _ -> true
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
else f
;;
2 changes: 1 addition & 1 deletion test/passing/tests/source-conventional.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ let ty_list : type a e. (a, e) ty -> (a vlist, e) ty =
(fun (type c) ->
(function Thd, Noarg -> `Nil | Ttl Thd, v -> `Cons v
: (noarg -> a * a vlist -> unit, c) ty_sel * c -> a vlist))
(* One can also write the type annotation directly *);
(* One can also write the type annotation directly *);
})

let v = variantize Enil (ty_list Int) (`Cons (1, `Cons (2, `Nil)))
Expand Down
2 changes: 1 addition & 1 deletion test/passing/tests/source.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ let ty_list : type a e. (a, e) ty -> (a vlist, e) ty =
(fun (type c) ->
( function Thd, Noarg -> `Nil | Ttl Thd, v -> `Cons v
: (noarg -> a * a vlist -> unit, c) ty_sel * c -> a vlist ) )
(* One can also write the type annotation directly *) } )
(* One can also write the type annotation directly *) } )

let v = variantize Enil (ty_list Int) (`Cons (1, `Cons (2, `Nil)))

Expand Down
Loading