Skip to content

Commit

Permalink
Fix the ordering of derived make's arguments
Browse files Browse the repository at this point in the history
This was broken by a change in ocaml-ppx#281

Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
  • Loading branch information
NathanReb committed Apr 26, 2024
1 parent 35dfd4a commit a32928f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
unreleased
----------

* Fix ordering of derived `make`'s arguments
#284
(@NathanReb)

6.0.1 (17/04/2024)
------------------

Expand Down
8 changes: 6 additions & 2 deletions src_plugins/make/ppx_deriving_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ let str_of_record_type ~quoter ~loc labels =
| None ->
record fields
in
List.fold_left (add_str_label_arg ~quoter ~loc) fn labels
(* The labels list must be reversed here so that the arguments are in the
same order as the record fields. *)
List.fold_left (add_str_label_arg ~quoter ~loc) fn (List.rev labels)

let str_of_type ({ ptype_loc = loc } as type_decl) =
let quoter = Ppx_deriving.create_quoter () in
Expand Down Expand Up @@ -156,7 +158,9 @@ let sig_of_record_type ~loc ~typ labels =
| None when has_option -> Typ.arrow Label.nolabel (tconstr "unit" []) typ
| None -> typ
in
List.fold_left add_sig_label_arg typ labels
(* The labels list must be reversed here so that the arguments are in the
same order as the record fields. *)
List.fold_left add_sig_label_arg typ (List.rev labels)

let sig_of_type ({ ptype_loc = loc } as type_decl) =
let typ = Ppx_deriving.core_type_of_type_decl type_decl in
Expand Down

0 comments on commit a32928f

Please sign in to comment.