@@ -96,28 +96,29 @@ let spec_of_ptyp
96
96
(* is_optional = false
97
97
*)
98
98
let refine_arg_type ~(nolabel :bool ) (ptyp : Ast_core_type.t )
99
- : Ast_core_type.t * External_arg_spec.attr =
100
- if ptyp.ptyp_desc = Ptyp_any then
101
- let ptyp_attrs = ptyp.ptyp_attributes in
102
- let result = Ast_attributes. iter_process_bs_string_or_int_as ptyp_attrs in
103
- (* when ppx start dropping attributes
104
- we should warn, there is a trade off whether
105
- we should warn dropped non bs attribute or not
106
- *)
107
- Bs_ast_invariant. warn_discarded_unused_attributes ptyp_attrs;
108
- match result with
109
- | None ->
110
- Bs_syntaxerr. err ptyp.ptyp_loc Invalid_underscore_type_in_external
111
- | Some (Int i ) -> (* (_[@bs.as ])*)
112
- (* This type is used in bs.obj only to construct obj type*)
113
- Ast_literal. type_int ~loc: ptyp.ptyp_loc () , Arg_cst (External_arg_spec. cst_int i)
114
- | Some (Str i )->
115
- Ast_literal. type_string ~loc: ptyp.ptyp_loc () , Arg_cst (External_arg_spec. cst_string i)
116
- | Some (Json_str s ) ->
117
- (* FIXME: This seems to be wrong in bs.obj, we should disable such payload in bs.obj *)
118
- Ast_literal. type_string ~loc: ptyp.ptyp_loc () , Arg_cst (External_arg_spec. cst_json ptyp.ptyp_loc s)
119
- else (* ([`a|`b] [@bs.string]) *)
120
- ptyp, spec_of_ptyp nolabel ptyp
99
+ : External_arg_spec.attr =
100
+ (if ptyp.ptyp_desc = Ptyp_any then
101
+ let ptyp_attrs = ptyp.ptyp_attributes in
102
+ let result = Ast_attributes. iter_process_bs_string_or_int_as ptyp_attrs in
103
+ (* when ppx start dropping attributes
104
+ we should warn, there is a trade off whether
105
+ we should warn dropped non bs attribute or not
106
+ *)
107
+ Bs_ast_invariant. warn_discarded_unused_attributes ptyp_attrs;
108
+ match result with
109
+ | None ->
110
+ Bs_syntaxerr. err ptyp.ptyp_loc Invalid_underscore_type_in_external
111
+ | Some (Int i ) -> (* (_[@bs.as ])*)
112
+ (* This type is used in bs.obj only to construct obj type*)
113
+ Arg_cst (External_arg_spec. cst_int i)
114
+ | Some (Str i )->
115
+ Arg_cst (External_arg_spec. cst_string i)
116
+ | Some (Json_str s ) ->
117
+ (* FIXME: This seems to be wrong in bs.obj, we should disable such payload in bs.obj *)
118
+ Arg_cst (External_arg_spec. cst_json ptyp.ptyp_loc s)
119
+ else (* ([`a|`b] [@bs.string]) *)
120
+ spec_of_ptyp nolabel ptyp
121
+ )
121
122
122
123
let refine_obj_arg_type ~(nolabel :bool ) (ptyp : Ast_core_type.t )
123
124
: Ast_core_type.t * External_arg_spec.attr =
@@ -882,15 +883,15 @@ let handle_attributes
882
883
let init : External_arg_spec.params * Ast_compatible.param_type list * int =
883
884
match external_desc.val_send_pipe with
884
885
| Some obj ->
885
- let new_ty, arg_type = refine_arg_type ~nolabel: true obj in
886
+ let arg_type = refine_arg_type ~nolabel: true obj in
886
887
begin match arg_type with
887
888
| Arg_cst _ ->
888
889
Location. raise_errorf ~loc: obj.ptyp_loc " [@bs.as] is not supported in bs.send type "
889
890
| _ ->
890
891
(* more error checking *)
891
892
[{arg_label = Arg_empty ; arg_type}],
892
893
[{label = Nolabel ;
893
- ty = new_ty ;
894
+ ty = obj ;
894
895
attr = [] ;
895
896
loc = obj.ptyp_loc} ],
896
897
0
@@ -929,20 +930,20 @@ let handle_attributes
929
930
Arg_optional , arg_type,
930
931
param_type :: arg_types end
931
932
| Labelled _ ->
932
- begin match refine_arg_type ~nolabel: false ty with
933
- | _ , (Arg_cst _ as arg_type ) ->
934
- Arg_label , arg_type, arg_types
935
- | new_ty , arg_type ->
936
- Arg_label , arg_type,
937
- {param_type with ty = new_ty} :: arg_types
938
- end
933
+ let arg_type = refine_arg_type ~nolabel: false ty in
934
+ Arg_label , arg_type,
935
+ ( match arg_type with
936
+ | Arg_cst _ ->
937
+ arg_types
938
+ | _ ->
939
+ param_type :: arg_types)
939
940
| Nolabel ->
940
- begin match refine_arg_type ~nolabel: true ty with
941
- | _ , (Arg_cst _ as arg_type ) ->
942
- Arg_empty , arg_type, arg_types
943
- | new_ty , arg_type ->
944
- Arg_empty , arg_type, {param_type with ty = new_ty} :: arg_types
945
- end
941
+ let arg_type = refine_arg_type ~nolabel: true ty in
942
+ Arg_empty , arg_type , (match arg_type with
943
+ | Arg_cst _ ->
944
+ arg_types
945
+ | _ ->
946
+ param_type :: arg_types)
946
947
in
947
948
({ arg_label ;
948
949
arg_type
0 commit comments