Skip to content

Commit b4d36a2

Browse files
Merge pull request #40 from andersfugmann/andersfugmann/ppxlib_0.36.0
Fix compatibility with ppxlib 0.36.0
2 parents 3402160 + cd65c84 commit b4d36a2

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
with:
3535
ocaml-compiler: ${{ matrix.ocaml-compiler }}
3636
opam-local-packages: ${{ matrix.packages }}
37+
opam-pin: false
3738

3839
- run: |
3940
opam install . --deps-only --with-doc --with-test

Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Changes marked with '*' indicates a changes that breaks backward compatibility
99
- [ ] Add namespaces to attributes
1010
- [ ] Unify xmlm and xml_light driver to share codebase
1111

12+
## 5.2.3 (unreleased)
13+
- [x] Compatibility against ppxlib 0.36.0
14+
1215
## 5.2.2
1316
- [x] Fix compatability with Ocaml 5
1417
- [x] Avoid linking against ppxlib

ppx/ppx_protocol_conv.ml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ and serialize_expr_of_tdecl t ~loc tdecl =
279279
serialize_expr_of_type_descr t ~loc core_type.ptyp_desc
280280
| None -> raise_errorf ~loc "Opaque types are not supported."
281281
end
282+
| Ptype_variant [] ->
283+
raise_errorf ~loc "ADTs with no constructors not supported"
282284
| Ptype_variant constrs ->
283285
test_constructor_mapping t constrs;
284286
let bindings, cases =
@@ -291,7 +293,7 @@ and serialize_expr_of_tdecl t ~loc tdecl =
291293
) constrs
292294
|> List.unzip
293295
in
294-
pexp_let ~loc Nonrecursive bindings @@ pexp_function ~loc cases
296+
pexp_let ~loc Nonrecursive bindings @@ pexp_function_cases ~loc cases
295297

296298
| Ptype_record labels ->
297299
let spec, patt, args = serialize_record t ~loc labels in
@@ -341,7 +343,7 @@ and serialize_expr_of_type_descr t ~loc = function
341343
) rows
342344
|> List.unzip
343345
in
344-
pexp_let ~loc Nonrecursive bindings @@ pexp_function ~loc cases
346+
pexp_let ~loc Nonrecursive bindings @@ pexp_function_cases ~loc cases
345347
| Ptyp_var core_type ->
346348
pexp_ident ~loc { loc; txt = Lident ( sprintf "__param_to_%s" core_type) }
347349
| Ptyp_arrow _ -> raise_errorf ~loc "Functions not supported"
@@ -351,6 +353,7 @@ and serialize_expr_of_type_descr t ~loc = function
351353
| Ptyp_class _
352354
| Ptyp_alias _
353355
| Ptyp_package _
356+
| Ptyp_open _
354357
| Ptyp_extension _ -> raise_errorf ~loc "Unsupported type descr"
355358

356359

@@ -534,7 +537,8 @@ and deserialize_expr_of_type_descr t ~loc = function
534537
| Ptyp_class _
535538
| Ptyp_alias _
536539
| Ptyp_package _
537-
| Ptyp_extension _ -> raise_errorf ~loc "Unsupported type descr"
540+
| Ptyp_extension _
541+
| Ptyp_open _ -> raise_errorf ~loc "Unsupported type descr"
538542

539543
let serialize_function_name ~loc ~driver name =
540544
let prefix = match name.txt with
@@ -586,28 +590,31 @@ let name_of_core_type ~prefix = function
586590
| { ptyp_desc = Ptyp_poly (_, _); _} -> failwith "Ptyp_poly "
587591
| { ptyp_desc = Ptyp_package _; _} -> failwith "Ptyp_package "
588592
| { ptyp_desc = Ptyp_extension _; _} -> failwith "Ptyp_extension "
593+
| { ptyp_desc = Ptyp_open _; _} -> failwith "Ptyp_open "
589594

590595

591596
let rec is_recursive_ct types = function
592597
| { ptyp_desc = Ptyp_var var; _ } ->
593598
List.mem types var ~equal:String.equal
594-
| { ptyp_desc = Ptyp_any; _ } -> false
595-
| { ptyp_desc = Ptyp_arrow _; _} -> false
596599
| { ptyp_desc = Ptyp_tuple cts; _} -> List.exists ~f:(is_recursive_ct types) cts
597600
| { ptyp_desc = Ptyp_constr (l, cts); _} ->
598601
List.mem types (string_of_ident_loc l).txt ~equal:String.equal ||
599602
List.exists ~f:(is_recursive_ct types) cts
600-
| { ptyp_desc = Ptyp_object _; _} -> false
601-
| { ptyp_desc = Ptyp_class _; _} -> false
602603
| { ptyp_desc = Ptyp_alias (c, _); _} -> is_recursive_ct types c
603604
| { ptyp_desc = Ptyp_variant (rows, _, _); _} ->
604605
List.exists ~f:(fun row -> match row.prf_desc with
605606
| Rtag (_, _, cts) -> List.exists ~f:(is_recursive_ct types) cts
606607
| Rinherit _ -> false
607608
) rows
608609
| { ptyp_desc = Ptyp_poly (_, ct); _} -> is_recursive_ct types ct
609-
| { ptyp_desc = Ptyp_package _; _} -> false
610-
| { ptyp_desc = Ptyp_extension _; _} -> false
610+
| { ptyp_desc = (Ptyp_any
611+
| Ptyp_arrow _
612+
| Ptyp_object _
613+
| Ptyp_class _
614+
| Ptyp_package _
615+
| Ptyp_extension _
616+
| Ptyp_open _); _ } -> false
617+
611618

612619
let is_recursive types = function
613620
| Ptype_abstract -> false
@@ -710,14 +717,16 @@ let make_recursive ~loc (e : expression) = function
710717
| true ->
711718
[%expr
712719
( let f = ref None in
713-
(fun t -> match !f with
714-
| None ->
715-
let f' = [%e e] in f := Some f'; f' t
716-
| Some f -> f t
717-
))
720+
(fun t ->
721+
match !f with
722+
| None ->
723+
let f' = [%e e] in
724+
f := Some f';
725+
f' t
726+
| Some f -> f t
727+
))
718728
]
719729

720-
721730
let to_protocol_str_type_decls t rec_flag ~loc tydecls =
722731
let (defs, is_recursive) =
723732
let is_recursive_f = is_recursive tydecls rec_flag in

ppx_protocol_conv.opam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ build: [
1111
["dune" "runtest" "-p" name "-j" jobs] {with-test}
1212
]
1313
depends: [
14-
"ocaml" {>= "4.07"}
15-
"base" {>= "v0.14.0" }
14+
"ocaml" {>= "4.08"}
15+
"base" {>= "v0.14.0"}
1616
"dune" {>= "1.2"}
17-
"ppxlib" {>= "0.9.0"}
17+
"ppxlib" {>= "0.36.0"}
1818
"ppx_sexp_conv" {with-test}
1919
"sexplib" {with-test}
2020
"alcotest" {with-test & >= "0.8.0"}

0 commit comments

Comments
 (0)