File tree Expand file tree Collapse file tree 6 files changed +225
-1
lines changed Expand file tree Collapse file tree 6 files changed +225
-1
lines changed Original file line number Diff line number Diff line change @@ -3807,6 +3807,13 @@ and fmt_module_type c ?(rec_ = false) ({ast= mty; _} as xmty) =
38073807 bdy= fmt_longident_loc c lid
38083808 ; epi= Some (fmt_attributes c pmty_attributes ~pre: (Break (1 , 0 ))) }
38093809 | Pmty_signature s ->
3810+ let is_signature_multiline =
3811+ match s with
3812+ | [] -> false
3813+ | _ :: _ ->
3814+ (List. hd_exn s).psig_loc.loc_start.pos_lnum
3815+ <> (List. last_exn s).psig_loc.loc_start.pos_lnum
3816+ in
38103817 let empty = List. is_empty s && not (Cmts. has_within c.cmts pmty_loc) in
38113818 let before = Cmts. fmt_before c pmty_loc in
38123819 let within = Cmts. fmt_within c ~pro: noop pmty_loc in
@@ -3821,7 +3828,8 @@ and fmt_module_type c ?(rec_ = false) ({ast= mty; _} as xmty) =
38213828 ; cls= noop
38223829 ; esp=
38233830 fmt_if (not empty)
3824- ( if c.conf.fmt_opts.break_struct.v then force_break
3831+ ( if c.conf.fmt_opts.break_struct.v || is_signature_multiline then
3832+ force_break
38253833 else break 1 0 )
38263834 ; epi=
38273835 Some
Original file line number Diff line number Diff line change @@ -68,3 +68,55 @@ include (
6868 include Ast_407
6969 end
7070 with module Location := Ast_407.Location)
71+
72+ module type S = sig
73+ type t =
74+ | AAaaaaaaaaaaaaaaaaaa
75+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
76+ | Ccccccccccccccccccccccc
77+ | Dddddddddddddddddd end
78+
79+ module S : sig
80+ type t =
81+ | AAaaaaaaaaaaaaaaaaaa
82+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
83+ | Ccccccccccccccccccccccc
84+ | Dddddddddddddddddd end = struct
85+ type t =
86+ | AAaaaaaaaaaaaaaaaaaa
87+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
88+ | Ccccccccccccccccccccccc
89+ | Dddddddddddddddddd
90+ end
91+
92+ module type Module_type_fail = sig
93+ include S
94+
95+ module F : functor (_ : T) -> sig end
96+
97+ include S
98+ end
99+
100+ module A : sig
101+ type a
102+
103+ type b
104+ end =
105+ B
106+
107+ module A : sig
108+ type a
109+
110+ type b
111+ end = struct
112+ type a
113+
114+ type b
115+ end
116+
117+ module type S = sig
118+ module Make (Config : sig
119+ val blah : string
120+
121+ val boo : int
122+ end) : S end
Original file line number Diff line number Diff line change @@ -75,3 +75,32 @@ include (
7575 include Ast_407
7676 end
7777 with module Location := Ast_407.Location)
78+
79+ module type S = sig
80+ type t =
81+ | AAaaaaaaaaaaaaaaaaaa
82+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
83+ | Ccccccccccccccccccccccc
84+ | Dddddddddddddddddd end
85+
86+ module S : sig
87+ type t =
88+ | AAaaaaaaaaaaaaaaaaaa
89+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
90+ | Ccccccccccccccccccccccc
91+ | Dddddddddddddddddd end = struct
92+ type t =
93+ | AAaaaaaaaaaaaaaaaaaa
94+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
95+ | Ccccccccccccccccccccccc
96+ | Dddddddddddddddddd
97+ end
98+
99+ module type Module_type_fail = sig
100+ include S module F : functor (_ : T) -> sig end include S end
101+
102+ module A : sig type a type b end = B
103+ module A : sig type a type b end = struct type a type b end
104+
105+ module type S = sig
106+ module Make (Config : sig val blah : string val boo : int end) : S end
Original file line number Diff line number Diff line change 8484include (
8585 Ast_407 :
8686 module type of struct include Ast_407 end with module Location := Ast_407.Location)
87+
88+ module type S = sig
89+ type t =
90+ | AAaaaaaaaaaaaaaaaaaa
91+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
92+ | Ccccccccccccccccccccccc
93+ | Dddddddddddddddddd end
94+
95+ module S : sig
96+ type t =
97+ | AAaaaaaaaaaaaaaaaaaa
98+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
99+ | Ccccccccccccccccccccccc
100+ | Dddddddddddddddddd end = struct
101+ type t =
102+ | AAaaaaaaaaaaaaaaaaaa
103+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
104+ | Ccccccccccccccccccccccc
105+ | Dddddddddddddddddd
106+ end
107+
108+ module type Module_type_fail = sig
109+ include S module F : functor (_ : T) -> sig end include S end
110+
111+ module A : sig type a type b end = B
112+ module A : sig type a type b end = struct type a type b end
113+
114+ module type S = sig module Make (Config : sig val blah : string val boo : int end) : S end
Original file line number Diff line number Diff line change @@ -83,3 +83,55 @@ include (
8383 include Ast_407
8484 end
8585 with module Location := Ast_407.Location )
86+
87+ module type S = sig
88+ type t =
89+ | AAaaaaaaaaaaaaaaaaaa
90+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
91+ | Ccccccccccccccccccccccc
92+ | Dddddddddddddddddd end
93+
94+ module S : sig
95+ type t =
96+ | AAaaaaaaaaaaaaaaaaaa
97+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
98+ | Ccccccccccccccccccccccc
99+ | Dddddddddddddddddd end = struct
100+ type t =
101+ | AAaaaaaaaaaaaaaaaaaa
102+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
103+ | Ccccccccccccccccccccccc
104+ | Dddddddddddddddddd
105+ end
106+
107+ module type Module_type_fail = sig
108+ include S
109+
110+ module F : functor (_ : T) -> sig end
111+
112+ include S
113+ end
114+
115+ module A : sig
116+ type a
117+
118+ type b
119+ end =
120+ B
121+
122+ module A : sig
123+ type a
124+
125+ type b
126+ end = struct
127+ type a
128+
129+ type b
130+ end
131+
132+ module type S = sig
133+ module Make (Config : sig
134+ val blah : string
135+
136+ val boo : int
137+ end) : S end
Original file line number Diff line number Diff line change @@ -88,3 +88,58 @@ include (
8888 module type of struct include Ast_407
8989 end
9090 with module Location := Ast_407. Location )
91+
92+ module type S = sig
93+ type t =
94+ | AAaaaaaaaaaaaaaaaaaa
95+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
96+ | Ccccccccccccccccccccccc
97+ | Dddddddddddddddddd
98+ end
99+
100+ module S : sig
101+ type t =
102+ | AAaaaaaaaaaaaaaaaaaa
103+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
104+ | Ccccccccccccccccccccccc
105+ | Dddddddddddddddddd
106+ end = struct
107+ type t =
108+ | AAaaaaaaaaaaaaaaaaaa
109+ | Bbbbbbbbbbbbbbbbbbbbbbbbbbb
110+ | Ccccccccccccccccccccccc
111+ | Dddddddddddddddddd
112+ end
113+
114+ module type Module_type_fail = sig
115+ include S
116+
117+ module F : functor (_ : T ) -> sig end
118+
119+ include S
120+ end
121+
122+ module A : sig
123+ type a
124+
125+ type b
126+ end =
127+ B
128+
129+ module A : sig
130+ type a
131+
132+ type b
133+ end = struct
134+ type a
135+
136+ type b
137+ end
138+
139+ module type S = sig
140+ module Make (Config : sig
141+ val blah : string
142+
143+ val boo : int
144+ end ) : S
145+ end
You can’t perform that action at this time.
0 commit comments