@@ -138,21 +138,20 @@ let from_labels ~loc arity labels
138
138
Typ. var ~loc (" a" ^ string_of_int i)))) in
139
139
let result_type =
140
140
Ast_comb. to_js_type loc
141
- (Typ . object_ ~loc
141
+ (Ast_compatible . object_ ~loc
142
142
(Ext_list. map2 (fun x y -> x.Asttypes. txt ,[] , y) labels tyvars) Closed )
143
143
in
144
144
Ext_list. fold_right2
145
145
(fun {Asttypes. loc ; txt = label }
146
- tyvar acc -> Typ. arrow ~loc label tyvar acc) labels tyvars result_type
146
+ tyvar acc -> Ast_compatible. label_arrow ~loc label tyvar acc) labels tyvars result_type
147
147
148
148
149
149
let make_obj ~loc xs =
150
150
Ast_comb. to_js_type loc
151
- (Ast_helper.Typ. object_ ~loc xs Closed )
151
+ (Ast_compatible. object_ ~loc xs Closed )
152
+
152
153
153
154
154
- let opt_arrow loc label ty1 ty2 =
155
- Typ. arrow ~loc (" ?" ^ label) ty1 ty2
156
155
(* *
157
156
158
157
{[ 'a . 'a -> 'b ]}
@@ -169,15 +168,19 @@ let rec get_uncurry_arity_aux (ty : t) acc =
169
168
| _ -> acc
170
169
171
170
(* *
172
- {[ unit -> 'a1 -> a2']} arity 2
173
171
{[ unit -> 'b ]} return arity 0
172
+ {[ unit -> 'a1 -> a2']} arity 2
174
173
{[ 'a1 -> 'a2 -> ... 'aN -> 'b ]} return arity N
175
174
*)
176
175
let get_uncurry_arity (ty : t ) =
177
176
match ty.ptyp_desc with
178
- | Ptyp_arrow (" " , {ptyp_desc = (Ptyp_constr ({txt = Lident " unit" }, [] ))},
179
- ({ptyp_desc = Ptyp_arrow _ } as rest )) -> `Arity (get_uncurry_arity_aux rest 1 )
180
- | Ptyp_arrow ("" , {ptyp_desc = (Ptyp_constr ({txt = Lident "unit" } , [] ))} , _ ) -> `Arity 0
177
+ | Ptyp_arrow (arg_label, {ptyp_desc = (Ptyp_constr ({txt = Lident " unit" }, [] ))},
178
+ rest ) when Ast_compatible. is_arg_label_simple arg_label ->
179
+ begin match rest with
180
+ | {ptyp_desc = Ptyp_arrow _ } ->
181
+ `Arity (get_uncurry_arity_aux rest 1 )
182
+ | _ -> `Arity 0
183
+ end
181
184
| Ptyp_arrow (_ ,_ ,rest ) ->
182
185
`Arity (get_uncurry_arity_aux rest 1 )
183
186
| _ -> `Not_function
0 commit comments