@@ -42,8 +42,8 @@ let handle_external loc (x : string) : Parsetree.expression =
4242 pexp_desc =
4343 Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
4444 ~pval_type:
45- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
46- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
45+ (Ast_helper.Typ. arrows
46+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
4747 (Ast_helper.Typ. any () ))
4848 [str_exp];
4949 }
@@ -71,8 +71,8 @@ let handle_debugger loc (payload : Ast_payload.t) =
7171 | PStr [] ->
7272 Ast_external_mk. local_external_apply loc ~pval_prim: [" %debugger" ]
7373 ~pval_type:
74- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
75- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
74+ (Ast_helper.Typ. arrows
75+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
7676 (Ast_literal. type_unit () ))
7777 [Ast_literal. val_unit ~loc () ]
7878 | _ ->
@@ -98,8 +98,8 @@ let handle_raw ~kind loc payload =
9898 pexp_desc =
9999 Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
100100 ~pval_type:
101- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
102- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
101+ (Ast_helper.Typ. arrows
102+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
103103 (Ast_helper.Typ. any () ))
104104 [exp];
105105 pexp_attributes =
@@ -125,20 +125,13 @@ let handle_ffi ~loc ~payload =
125125 let wrap_type_constraint (e : Parsetree.expression ) =
126126 let loc = e.pexp_loc in
127127 let any = Ast_helper.Typ. any ~loc: e.pexp_loc () in
128- let unit = Ast_literal. type_unit ~loc () in
129- let rec arrow ~arity =
130- if arity = 0 then
131- Ast_helper.Typ. arrow ~arity: None ~loc
132- {attrs = [] ; lbl = Nolabel ; typ = unit }
133- any
134- else if arity = 1 then
135- Ast_helper.Typ. arrow ~arity: None ~loc
136- {attrs = [] ; lbl = Nolabel ; typ = any}
137- any
138- else
139- Ast_helper.Typ. arrow ~loc ~arity: None
140- {attrs = [] ; lbl = Nolabel ; typ = any}
141- (arrow ~arity: (arity - 1 ))
128+ let arrow ~arity =
129+ let effective_arity = if arity = 0 then 1 else arity in
130+ let args =
131+ Ext_list. init effective_arity (fun _ ->
132+ ({attrs = [] ; lbl = Nolabel ; typ = any} : Parsetree.arg ))
133+ in
134+ Ast_helper.Typ. arrows ~loc args any
142135 in
143136 match ! is_function with
144137 | Some arity ->
@@ -156,8 +149,8 @@ let handle_ffi ~loc ~payload =
156149 pexp_desc =
157150 Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
158151 ~pval_type:
159- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
160- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
152+ (Ast_helper.Typ. arrows
153+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
161154 (Ast_helper.Typ. any () ))
162155 [exp];
163156 pexp_attributes =
@@ -175,8 +168,8 @@ let handle_raw_structure loc payload =
175168 pexp_desc =
176169 Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_stmt" ]
177170 ~pval_type:
178- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
179- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
171+ (Ast_helper.Typ. arrows
172+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
180173 (Ast_helper.Typ. any () ))
181174 [exp];
182175 }
0 commit comments