@@ -450,6 +450,15 @@ let polyvar_ident_to_string poly_var_ident =
450
450
Doc. concat [Doc. text " #" ; print_poly_var_ident poly_var_ident]
451
451
|> Doc. to_string ~width: 80
452
452
453
+ let find_inline_record_definition inline_record_name
454
+ (inline_record_definitions : Parsetree.type_declaration list option ) =
455
+ match inline_record_definitions with
456
+ | None -> None
457
+ | Some inline_record_definitions ->
458
+ inline_record_definitions
459
+ |> List. find_opt (fun (r : Parsetree.type_declaration ) ->
460
+ r.ptype_name.txt = inline_record_name)
461
+
453
462
let print_lident l =
454
463
let flat_lid_opt lid =
455
464
let rec flat accu = function
@@ -1714,21 +1723,17 @@ and print_typ_expr ?inline_record_definitions ~(state : State.t)
1714
1723
print_object ~state ~inline: false fields open_flag cmt_tbl
1715
1724
| Ptyp_arrow {arity} -> print_arrow ~arity typ_expr
1716
1725
| Ptyp_constr ({txt = Lident inline_record_name}, [] )
1717
- when inline_record_definitions |> Option. is_some
1718
- && String. contains inline_record_name '.' -> (
1719
- let inline_record_definitions =
1720
- match inline_record_definitions with
1721
- | None -> []
1722
- | Some v -> v
1723
- in
1724
- let record_definition =
1726
+ when inline_record_definitions
1727
+ |> find_inline_record_definition inline_record_name
1728
+ |> Option. is_some -> (
1729
+ match
1725
1730
inline_record_definitions
1726
- |> List. find_opt (fun (r : Parsetree.type_declaration ) ->
1727
- r.ptype_name.txt = inline_record_name)
1728
- in
1729
- match record_definition with
1731
+ |> find_inline_record_definition inline_record_name
1732
+ with
1730
1733
| Some {ptype_kind = Ptype_record lds } ->
1731
- print_record_declaration ~inline_record_definitions ~state lds cmt_tbl
1734
+ print_record_declaration
1735
+ ~inline_record_definitions: (inline_record_definitions |> Option. get)
1736
+ ~state lds cmt_tbl
1732
1737
| _ -> assert false )
1733
1738
| Ptyp_constr
1734
1739
(longident_loc, [{ptyp_desc = Ptyp_object (fields, open_flag)}]) ->
0 commit comments