@@ -398,7 +398,14 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
398398 | _ ->
399399 Location. raise_errorf ~loc
400400 " expect label, optional, or unit here" )
401- | Labelled name -> (
401+ | Labelled label -> (
402+ let fieldName =
403+ match
404+ Ast_attributes. iter_process_bs_string_as param_type.attr
405+ with
406+ | Some alias -> alias
407+ | None -> label
408+ in
402409 let obj_arg_type = refine_obj_arg_type ~nolabel: false ty in
403410 match obj_arg_type with
404411 | Ignore ->
@@ -407,39 +414,39 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
407414 result_types )
408415 | Arg_cst _ ->
409416 ( {
410- obj_arg_label = External_arg_spec. obj_label name ;
417+ obj_arg_label = External_arg_spec. obj_label fieldName ;
411418 obj_arg_type;
412419 },
413420 arg_types,
414421 (* ignored in [arg_types], reserved in [result_types] *)
415422 result_types )
416423 | Nothing ->
417424 ( {
418- obj_arg_label = External_arg_spec. obj_label name ;
425+ obj_arg_label = External_arg_spec. obj_label fieldName ;
419426 obj_arg_type;
420427 },
421428 param_type :: arg_types,
422- Parsetree. Otag ({Asttypes. txt = name ; loc}, [] , ty)
429+ Parsetree. Otag ({Asttypes. txt = fieldName ; loc}, [] , ty)
423430 :: result_types )
424431 | Int _ ->
425432 ( {
426- obj_arg_label = External_arg_spec. obj_label name ;
433+ obj_arg_label = External_arg_spec. obj_label fieldName ;
427434 obj_arg_type;
428435 },
429436 param_type :: arg_types,
430437 Otag
431- ( {Asttypes. txt = name ; loc},
438+ ( {Asttypes. txt = fieldName ; loc},
432439 [] ,
433440 Ast_literal. type_int ~loc () )
434441 :: result_types )
435442 | Poly_var_string _ ->
436443 ( {
437- obj_arg_label = External_arg_spec. obj_label name ;
444+ obj_arg_label = External_arg_spec. obj_label fieldName ;
438445 obj_arg_type;
439446 },
440447 param_type :: arg_types,
441448 Otag
442- ( {Asttypes. txt = name ; loc},
449+ ( {Asttypes. txt = fieldName ; loc},
443450 [] ,
444451 Ast_literal. type_string ~loc () )
445452 :: result_types )
@@ -449,11 +456,18 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
449456 | Extern_unit -> assert false
450457 | Poly_var _ ->
451458 Location. raise_errorf ~loc
452- " %@obj label %s does not support such arg type" name
459+ " %@obj label %s does not support such arg type" label
453460 | Unwrap ->
454461 Location. raise_errorf ~loc
455- " %@obj label %s does not support %@unwrap arguments" name)
456- | Optional name -> (
462+ " %@obj label %s does not support %@unwrap arguments" label)
463+ | Optional label -> (
464+ let fieldName =
465+ match
466+ Ast_attributes. iter_process_bs_string_as param_type.attr
467+ with
468+ | Some alias -> alias
469+ | None -> label
470+ in
457471 let obj_arg_type = get_opt_arg_type ~nolabel: false ty in
458472 match obj_arg_type with
459473 | Ignore ->
@@ -469,35 +483,35 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
469483 in
470484 ( {
471485 obj_arg_label =
472- External_arg_spec. optional for_sure_not_nested name ;
486+ External_arg_spec. optional for_sure_not_nested fieldName ;
473487 obj_arg_type;
474488 },
475489 param_type :: arg_types,
476490 Parsetree. Otag
477- ( {Asttypes. txt = name ; loc},
491+ ( {Asttypes. txt = fieldName ; loc},
478492 [] ,
479493 Ast_comb. to_undefined_type loc ty )
480494 :: result_types )
481495 | Int _ ->
482496 ( {
483- obj_arg_label = External_arg_spec. optional true name ;
497+ obj_arg_label = External_arg_spec. optional true fieldName ;
484498 obj_arg_type;
485499 },
486500 param_type :: arg_types,
487501 Otag
488- ( {Asttypes. txt = name ; loc},
502+ ( {Asttypes. txt = fieldName ; loc},
489503 [] ,
490504 Ast_comb. to_undefined_type loc
491505 @@ Ast_literal. type_int ~loc () )
492506 :: result_types )
493507 | Poly_var_string _ ->
494508 ( {
495- obj_arg_label = External_arg_spec. optional true name ;
509+ obj_arg_label = External_arg_spec. optional true fieldName ;
496510 obj_arg_type;
497511 },
498512 param_type :: arg_types,
499513 Otag
500- ( {Asttypes. txt = name ; loc},
514+ ( {Asttypes. txt = fieldName ; loc},
501515 [] ,
502516 Ast_comb. to_undefined_type loc
503517 @@ Ast_literal. type_string ~loc () )
@@ -511,10 +525,10 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
511525 | Extern_unit -> assert false
512526 | Poly_var _ ->
513527 Location. raise_errorf ~loc
514- " %@obj label %s does not support such arg type" name
528+ " %@obj label %s does not support such arg type" label
515529 | Unwrap ->
516530 Location. raise_errorf ~loc
517- " %@obj label %s does not support %@unwrap arguments" name )
531+ " %@obj label %s does not support %@unwrap arguments" label )
518532 in
519533 (new_arg_label :: arg_labels, new_arg_types, output_tys))
520534 in
0 commit comments