Skip to content

Janestreet profile: do not break fun _ -> function #2460

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

Merged
merged 3 commits into from
Oct 10, 2023
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 @@ -10,6 +10,7 @@ profile. This started with version 0.26.0.

- Documentation comments are now formatted by default (#2390, @Julow)
Use the option `parse-docstrings = false` to disable.
- \* Janestreet profile: do not break `fun _ -> function` (#2460, @tdelvecchio-jsc)

### Fixed

Expand Down
4 changes: 1 addition & 3 deletions lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,7 @@ and fmt_fun ?force_closing_paren
let body =
let box =
match xbody.ast.pexp_desc with
| Pexp_fun _ | Pexp_newtype _ -> Some false
| Pexp_function _ when not c.conf.fmt_opts.ocp_indent_compat.v ->
Some false
| Pexp_fun _ | Pexp_newtype _ | Pexp_function _ -> Some false
| _ -> None
in
fmt_expression c ?box xbody
Expand Down
6 changes: 2 additions & 4 deletions test/passing/tests/js_source.ml.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -10168,8 +10168,7 @@ let _ =
Foooooooooooooooooooo.foooooooooooooooooooo
foooooooooooooooooooo
foooooooooooooooooooo
(fun x ->
function
(fun x -> function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
;;
Expand All @@ -10178,8 +10177,7 @@ let _ =
Foooooooooooooooooooo.foooooooooooooooooooo
foooooooooooooooooooo
foooooooooooooooooooo
~x:(fun x ->
function
~x:(fun x -> function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
;;
Expand Down
14 changes: 6 additions & 8 deletions test/passing/tests/js_source.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10168,20 +10168,18 @@ let _ =
Foooooooooooooooooooo.foooooooooooooooooooo
foooooooooooooooooooo
foooooooooooooooooooo
(fun x ->
function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
(fun x -> function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
;;

let _ =
Foooooooooooooooooooo.foooooooooooooooooooo
foooooooooooooooooooo
foooooooooooooooooooo
~x:(fun x ->
function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
~x:(fun x -> function
| Foooooooooooooooooooo -> foooooooooooooooooooo
| Foooooooooooooooooooo -> foooooooooooooooooooo)
;;

let _ =
Expand Down