Skip to content

Commit a32928f

Browse files
committed
Fix the ordering of derived make's arguments
This was broken by a change in ocaml-ppx#281 Signed-off-by: Nathan Rebours <[email protected]>
1 parent 35dfd4a commit a32928f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
unreleased
2+
----------
3+
4+
* Fix ordering of derived `make`'s arguments
5+
#284
6+
(@NathanReb)
7+
18
6.0.1 (17/04/2024)
29
------------------
310

src_plugins/make/ppx_deriving_make.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ let str_of_record_type ~quoter ~loc labels =
9797
| None ->
9898
record fields
9999
in
100-
List.fold_left (add_str_label_arg ~quoter ~loc) fn labels
100+
(* The labels list must be reversed here so that the arguments are in the
101+
same order as the record fields. *)
102+
List.fold_left (add_str_label_arg ~quoter ~loc) fn (List.rev labels)
101103

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

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

0 commit comments

Comments
 (0)