From c3227d1f1ef15d907387dba38c26ea0167645b47 Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 26 Sep 2024 20:16:13 +0100 Subject: [PATCH] Add OCaml 5.3 support --- src/api/ppx_deriving.cppo.ml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api/ppx_deriving.cppo.ml b/src/api/ppx_deriving.cppo.ml index b14785b..b1f800d 100644 --- a/src/api/ppx_deriving.cppo.ml +++ b/src/api/ppx_deriving.cppo.ml @@ -174,8 +174,18 @@ let raise_errorf ?sub ?loc fmt = #if OCAML_VERSION >= (4, 08, 0) let sub = let msg_of_error err = +#if OCAML_VERSION >= (5, 3, 0) + let loc = err.Location.main.loc in + let print_report fmt x = + Ocaml_common.Format_doc.deprecated_printer + (fun fmt -> Location.print_report fmt x) fmt + in + Location.msg ~loc "%a" print_report err +#else { txt = (fun fmt -> Location.print_report fmt err); - loc = err.Location.main.loc } in + loc = err.Location.main.loc } +#endif + in Option.map (List.map msg_of_error) sub in #endif let err = Location.error ?sub ?loc str in