From 2acf48121e9eea42d073a4e3e0b5d888ad1da757 Mon Sep 17 00:00:00 2001 From: tatchi Date: Mon, 10 Jan 2022 18:49:35 +0100 Subject: [PATCH] add support for OCaml 4.13 --- src/compat/gen.ml | 1 + src/compat/types_type_kind_ge_000.ml | 3 +++ src/compat/types_type_kind_ge_413.ml | 11 +++++++++++ src/ppx_import.ml | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/compat/types_type_kind_ge_000.ml create mode 100644 src/compat/types_type_kind_ge_413.ml diff --git a/src/compat/gen.ml b/src/compat/gen.ml index bb8175b..1d318cf 100644 --- a/src/compat/gen.ml +++ b/src/compat/gen.ml @@ -14,6 +14,7 @@ let make_version ~version f_prefix = let include_table = [ ("types_module_type", [(4, 10); (4, 8)]) ; ("types_signature_item", [(4, 8)]) + ; ("types_type_kind", [(4, 13)]) ; ("init_path", [(4, 9)]) ; ("env_lookup", [(4, 10)]) ] diff --git a/src/compat/types_type_kind_ge_000.ml b/src/compat/types_type_kind_ge_000.ml new file mode 100644 index 0000000..809646d --- /dev/null +++ b/src/compat/types_type_kind_ge_000.ml @@ -0,0 +1,3 @@ +type type_kind_407 = Types.type_kind + +let migrate_type_kind : Types.type_kind -> type_kind_407 = fun x -> x diff --git a/src/compat/types_type_kind_ge_413.ml b/src/compat/types_type_kind_ge_413.ml new file mode 100644 index 0000000..d37b252 --- /dev/null +++ b/src/compat/types_type_kind_ge_413.ml @@ -0,0 +1,11 @@ +type ('lbl, 'cstr) type_kind_407 = + | Type_abstract + | Type_record of 'lbl list * Types.record_representation + | Type_variant of 'cstr list + | Type_open + +let migrate_type_kind : ('lbl, 'cstr) Types.type_kind -> ('lbl, 'cstr) type_kind_407 = function + | Type_abstract -> Type_abstract + | Type_record (lbl, repr) -> Type_record (lbl, repr) + | Type_variant (cstr, _) -> Type_variant cstr + | Type_open -> Type_open diff --git a/src/ppx_import.ml b/src/ppx_import.ml index a6177c5..369f992 100644 --- a/src/ppx_import.ml +++ b/src/ppx_import.ml @@ -267,7 +267,7 @@ let ptype_decl_of_ttype_decl ~manifest ~subst ptype_name ; pld_attributes = Tt.copy_attributes ld.ld_attributes }) in Ppxlib.( - match ttype_decl.type_kind with + match Compat.migrate_type_kind ttype_decl.type_kind with | Type_abstract -> Ptype_abstract | Type_open -> Ptype_open | Type_record (labels, _) -> Ptype_record (map_labels labels)