From e16e4d0602e88c0282f07ba3e15b08f2c812ba8c Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Sat, 23 May 2020 15:44:36 +0200 Subject: [PATCH] Define Pconst_string_patt Suggested by Gabriel Scherer. https://github.com/ocaml-ppx/ppx_deriving/pull/222#discussion_r429545180 --- src/api/ppx_deriving.cppo.ml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/api/ppx_deriving.cppo.ml b/src/api/ppx_deriving.cppo.ml index 1d2259fd..20f9d238 100644 --- a/src/api/ppx_deriving.cppo.ml +++ b/src/api/ppx_deriving.cppo.ml @@ -27,6 +27,12 @@ #define Rinherit_patt(typ) {prf_desc = Rinherit(typ); _} #endif +#if OCAML_VERSION < (4, 11, 0) +#define Pconst_string_patt(s, loc) Pconst_string(s, loc) +#else +#define Pconst_string_patt(s, loc) Pconst_string(s, loc, _) +#endif + open Longident open Location open Asttypes @@ -152,12 +158,7 @@ type constant = let string_of_constant_opt (constant : constant) : string option = match constant with - #if OCAML_VERSION >= (4, 11, 0) - | Pconst_string (s, _, _) -> - #else - | Pconst_string (s, _) -> - #endif - Some s + | Pconst_string_patt (s, _) -> Some s | _ -> None let string_of_expression_opt (e : Parsetree.expression) : string option =