@@ -450,6 +450,15 @@ let polyvar_ident_to_string poly_var_ident =
450450 Doc. concat [Doc. text " #" ; print_poly_var_ident poly_var_ident]
451451 |> Doc. to_string ~width: 80
452452
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+
453462let print_lident l =
454463 let flat_lid_opt lid =
455464 let rec flat accu = function
@@ -1714,21 +1723,17 @@ and print_typ_expr ?inline_record_definitions ~(state : State.t)
17141723 print_object ~state ~inline: false fields open_flag cmt_tbl
17151724 | Ptyp_arrow {arity} -> print_arrow ~arity typ_expr
17161725 | 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
17251730 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
17301733 | 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
17321737 | _ -> assert false )
17331738 | Ptyp_constr
17341739 (longident_loc, [{ptyp_desc = Ptyp_object (fields, open_flag)}]) ->
0 commit comments