Skip to content

Commit 9d90881

Browse files
authored
Ppx: cosmetic change, more control over uid generation order (#1914)
* Ppx: fix order of parameter ident generation * promote
1 parent a8e8d2c commit 9d90881

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

ppx/ppx_js/lib_internal/ppx_js_internal.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ let method_call ~loc ~apply_loc obj (meth, meth_loc) args =
305305
| eobj :: eargs ->
306306
let eargs = inject_args eargs in
307307
Js.unsafe "meth_call" [ eobj; ocaml_str (unescape meth); eargs ])
308-
(Arg.make () :: List.map args ~f:(fun (label, _) -> Arg.make ~label ()))
308+
(List.map (nolabel :: List.map ~f:fst args) ~f:(fun label -> Arg.make ~label ()))
309309
in
310310
Exp.apply
311311
~loc:apply_loc
@@ -455,7 +455,7 @@ let new_object constr args =
455455
(function
456456
| constr :: args -> Js.unsafe "new_obj" [ constr; inject_args args ]
457457
| _ -> assert false)
458-
(Arg.make () :: List.map args ~f:(fun (label, _) -> Arg.make ~label ()))
458+
(List.map (nolabel :: List.map ~f:fst args) ~f:(fun label -> Arg.make ~label ()))
459459
in
460460
let gloc = { constr.loc with loc_ghost = true } in
461461
Exp.apply
@@ -583,12 +583,14 @@ let preprocess_literal_object mappper fields :
583583
let body, body_ty = drop_pexp_poly (mappper body) in
584584
let rec create_meth_ty exp =
585585
match exp.pexp_desc with
586-
| Pexp_fun (label, _, _, body) -> Arg.make ~label () :: create_meth_ty body
587-
| Pexp_function _ -> [ Arg.make () ]
586+
| Pexp_fun (label, _, _, body) -> label :: create_meth_ty body
587+
| Pexp_function _ -> [ nolabel ]
588588
| Pexp_newtype (_, body) -> create_meth_ty body
589589
| _ -> []
590590
in
591-
let fun_ty = create_meth_ty body in
591+
let fun_ty =
592+
List.map ~f:(fun label -> Arg.make ~label ()) (create_meth_ty body)
593+
in
592594
let body =
593595
match body_ty with
594596
| None -> body

ppx/ppx_js/tests/gen.mlt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ let o () =
105105
{|
106106
let o () =
107107
(fun (type res) ->
108-
fun (type t1) ->
109-
fun (type t0) ->
108+
fun (type t0) ->
109+
fun (type t1) ->
110110
fun (type t2) ->
111-
fun (t2 : res Js_of_ocaml.Js.t -> t1 -> t0 -> t2)
111+
fun (t2 : res Js_of_ocaml.Js.t -> t0 -> t1 -> t2)
112112
(_ :
113113
res Js_of_ocaml.Js.t ->
114-
(res Js_of_ocaml.Js.t -> t1 -> t0 -> t2 Js_of_ocaml.Js.meth)
114+
(res Js_of_ocaml.Js.t -> t0 -> t1 -> t2 Js_of_ocaml.Js.meth)
115115
-> res)
116116
: res Js_of_ocaml.Js.t->
117117
Js_of_ocaml.Js.Unsafe.obj
@@ -134,13 +134,13 @@ let o () =
134134
{|
135135
let o () =
136136
(fun (type res) ->
137-
fun (type t4) ->
138-
fun (type t3) ->
137+
fun (type t3) ->
138+
fun (type t4) ->
139139
fun (type t5) ->
140-
fun (t5 : res Js_of_ocaml.Js.t -> t4 -> t3 -> t5)
140+
fun (t5 : res Js_of_ocaml.Js.t -> t3 -> t4 -> t5)
141141
(_ :
142142
res Js_of_ocaml.Js.t ->
143-
(res Js_of_ocaml.Js.t -> t4 -> t3 -> t5 Js_of_ocaml.Js.meth)
143+
(res Js_of_ocaml.Js.t -> t3 -> t4 -> t5 Js_of_ocaml.Js.meth)
144144
-> res)
145145
: res Js_of_ocaml.Js.t->
146146
Js_of_ocaml.Js.Unsafe.obj
@@ -163,13 +163,13 @@ let o () =
163163
{|
164164
let o () =
165165
(fun (type res) ->
166-
fun (type t7) ->
167-
fun (type t6) ->
166+
fun (type t6) ->
167+
fun (type t7) ->
168168
fun (type t8) ->
169-
fun (t8 : res Js_of_ocaml.Js.t -> t7 -> t6 -> t8)
169+
fun (t8 : res Js_of_ocaml.Js.t -> t6 -> t7 -> t8)
170170
(_ :
171171
res Js_of_ocaml.Js.t ->
172-
(res Js_of_ocaml.Js.t -> t7 -> t6 -> t8 Js_of_ocaml.Js.meth)
172+
(res Js_of_ocaml.Js.t -> t6 -> t7 -> t8 Js_of_ocaml.Js.meth)
173173
-> res)
174174
: res Js_of_ocaml.Js.t->
175175
Js_of_ocaml.Js.Unsafe.obj
@@ -192,14 +192,14 @@ let o () =
192192
{|
193193
let o () =
194194
(fun (type res) ->
195-
fun (type t10) ->
196-
fun (type t9) ->
195+
fun (type t9) ->
196+
fun (type t10) ->
197197
fun (type t11) ->
198-
fun (t11 : res Js_of_ocaml.Js.t -> t10 -> t9 -> t11)
198+
fun (t11 : res Js_of_ocaml.Js.t -> t9 -> t10 -> t11)
199199
(_ :
200200
res Js_of_ocaml.Js.t ->
201201
(res Js_of_ocaml.Js.t ->
202-
t10 -> t9 -> t11 Js_of_ocaml.Js.meth)
202+
t9 -> t10 -> t11 Js_of_ocaml.Js.meth)
203203
-> res)
204204
: res Js_of_ocaml.Js.t->
205205
Js_of_ocaml.Js.Unsafe.obj
@@ -224,14 +224,14 @@ let o () =
224224
{|
225225
let o () =
226226
(fun (type res) ->
227-
fun (type t13) ->
228-
fun (type t12) ->
227+
fun (type t12) ->
228+
fun (type t13) ->
229229
fun (type t14) ->
230-
fun (t14 : res Js_of_ocaml.Js.t -> t13 -> t12 -> t14)
230+
fun (t14 : res Js_of_ocaml.Js.t -> t12 -> t13 -> t14)
231231
(_ :
232232
res Js_of_ocaml.Js.t ->
233233
(res Js_of_ocaml.Js.t ->
234-
t13 -> t12 -> t14 Js_of_ocaml.Js.meth)
234+
t12 -> t13 -> t14 Js_of_ocaml.Js.meth)
235235
-> res)
236236
: res Js_of_ocaml.Js.t->
237237
Js_of_ocaml.Js.Unsafe.obj
@@ -257,14 +257,14 @@ let o () =
257257
{|
258258
let o () =
259259
(fun (type res) ->
260-
fun (type t16) ->
261-
fun (type t15) ->
260+
fun (type t15) ->
261+
fun (type t16) ->
262262
fun (type t17) ->
263-
fun (t17 : res Js_of_ocaml.Js.t -> t16 -> t15 -> t17)
263+
fun (t17 : res Js_of_ocaml.Js.t -> t15 -> t16 -> t17)
264264
(_ :
265265
res Js_of_ocaml.Js.t ->
266266
(res Js_of_ocaml.Js.t ->
267-
t16 -> t15 -> t17 Js_of_ocaml.Js.meth)
267+
t15 -> t16 -> t17 Js_of_ocaml.Js.meth)
268268
-> res)
269269
: res Js_of_ocaml.Js.t->
270270
Js_of_ocaml.Js.Unsafe.obj
@@ -290,14 +290,14 @@ let o () =
290290
{|
291291
let o () =
292292
(fun (type res) ->
293-
fun (type t19) ->
294-
fun (type t18) ->
293+
fun (type t18) ->
294+
fun (type t19) ->
295295
fun (type t20) ->
296-
fun (t20 : res Js_of_ocaml.Js.t -> t19 -> t18 -> t20)
296+
fun (t20 : res Js_of_ocaml.Js.t -> t18 -> t19 -> t20)
297297
(_ :
298298
res Js_of_ocaml.Js.t ->
299299
(res Js_of_ocaml.Js.t ->
300-
t19 -> t18 -> t20 Js_of_ocaml.Js.meth)
300+
t18 -> t19 -> t20 Js_of_ocaml.Js.meth)
301301
-> res)
302302
: res Js_of_ocaml.Js.t->
303303
Js_of_ocaml.Js.Unsafe.obj
@@ -323,14 +323,14 @@ let o () =
323323
{|
324324
let o () =
325325
(fun (type res) ->
326-
fun (type t22) ->
327-
fun (type t21) ->
326+
fun (type t21) ->
327+
fun (type t22) ->
328328
fun (type t23) ->
329-
fun (t23 : res Js_of_ocaml.Js.t -> t22 -> t21 -> t23)
329+
fun (t23 : res Js_of_ocaml.Js.t -> t21 -> t22 -> t23)
330330
(_ :
331331
res Js_of_ocaml.Js.t ->
332332
(res Js_of_ocaml.Js.t ->
333-
t22 -> t21 -> t23 Js_of_ocaml.Js.meth)
333+
t21 -> t22 -> t23 Js_of_ocaml.Js.meth)
334334
-> res)
335335
: res Js_of_ocaml.Js.t->
336336
Js_of_ocaml.Js.Unsafe.obj

0 commit comments

Comments
 (0)