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

Remove parens around match sugared type constraint #2310

Merged
merged 2 commits into from
Mar 20, 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
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- Restore short form for first-class modules: `((module M) : (module S))` is formatted as `(module M : S)`) (#2280, #2300, @gpetiot, @Julow)
- Restore short form formatting of record field aliases (#2282, @gpetiot)
- Tweaks the JaneStreet profile to be more consistent with ocp-indent (#2281, #2284, #2289, #2299, #2302, @gpetiot, @Julow)
- Tweaks the JaneStreet profile to be more consistent with ocp-indent (#2281, #2284, #2289, #2299, #2302, #2310, @gpetiot, @Julow)
- Improve formatting of class signatures (#2301, @gpetiot, @Julow)

### New features
Expand Down
12 changes: 6 additions & 6 deletions lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,16 @@ and fmt_type_cstr c ?constraint_ctx xtyp =

and type_constr_and_body c xbody =
let body = xbody.ast in
let ctx = Exp body in
let fmt_cstr_and_xbody typ exp =
( Some (fmt_type_cstr c ~constraint_ctx:`Fun (sub_typ ~ctx typ))
, sub_exp ~ctx exp )
in
match xbody.ast.pexp_desc with
| Pexp_constraint (exp, typ) ->
Cmts.relocate c.cmts ~src:body.pexp_loc ~before:exp.pexp_loc
~after:exp.pexp_loc ;
fmt_cstr_and_xbody typ exp
let typ_ctx = Exp body in
let exp_ctx =
Exp Ast_helper.(Exp.fun_ Nolabel None (Pat.any ()) exp)
in
( Some (fmt_type_cstr c ~constraint_ctx:`Fun (sub_typ ~ctx:typ_ctx typ))
, sub_exp ~ctx:exp_ctx exp )
| _ -> (None, xbody)

and fmt_arrow_param c ctx {pap_label= lI; pap_loc= locI; pap_type= tI} =
Expand Down
9 changes: 9 additions & 0 deletions test/passing/tests/js_source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7663,3 +7663,12 @@ let _ =
eeee) -> FFFFFFFFF gg)
~h
;;

let _ =
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
~f:(fun (type a) foooooooooooooooooooooooooooooooooo : 'a ->
match fooooooooooooooooooooooooooooooooooooooo with
| Fooooooooooooooooooooooooooooooooooooooo -> x
| Fooooooooooooooooooooooooooooooooooooooo -> x )
10 changes: 10 additions & 0 deletions test/passing/tests/js_source.ml.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -9871,3 +9871,13 @@ let _ =
(_ : (ccccccccccccc * ddddddddddddddddddddddddddddd) eeee) -> FFFFFFFFF gg)
~h
;;

let _ =
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
~f:(fun (type a) foooooooooooooooooooooooooooooooooo : 'a ->
match fooooooooooooooooooooooooooooooooooooooo with
| Fooooooooooooooooooooooooooooooooooooooo -> x
| Fooooooooooooooooooooooooooooooooooooooo -> x)
;;
10 changes: 10 additions & 0 deletions test/passing/tests/js_source.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -9871,3 +9871,13 @@ let _ =
(_ : (ccccccccccccc * ddddddddddddddddddddddddddddd) eeee) -> FFFFFFFFF gg)
~h
;;

let _ =
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooo
~f:(fun (type a) foooooooooooooooooooooooooooooooooo : 'a ->
match fooooooooooooooooooooooooooooooooooooooo with
| Fooooooooooooooooooooooooooooooooooooooo -> x
| Fooooooooooooooooooooooooooooooooooooooo -> x)
;;