File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1313,6 +1313,20 @@ let transl_exception env sext =
1313
1313
let newenv = Env. add_extension ~check: true ext.ext_id ext.ext_type env in
1314
1314
ext, newenv
1315
1315
1316
+ let customize_arity arity pval_attributes =
1317
+ let cur_arity = ref arity in
1318
+ List. iter (fun (x :Parsetree.attribute ) ->
1319
+ match x with
1320
+ | {txt = " internal.arity" ;_},
1321
+ PStr [ {pstr_desc = Pstr_eval
1322
+ (
1323
+ ({pexp_desc = Pexp_constant (Const_int i)} :
1324
+ Parsetree. expression) ,_)}]
1325
+ -> if i < ! cur_arity then cur_arity := i
1326
+ | _ -> ()
1327
+ ) pval_attributes ;
1328
+ ! cur_arity
1329
+
1316
1330
(* Translate a value declaration *)
1317
1331
let transl_value_decl env loc valdecl =
1318
1332
let cty = Typetexp. transl_type_scheme env valdecl.pval_type in
@@ -1323,7 +1337,7 @@ let transl_value_decl env loc valdecl =
1323
1337
{ val_type = ty; val_kind = Val_reg ; Types. val_loc = loc;
1324
1338
val_attributes = valdecl.pval_attributes }
1325
1339
| decl ->
1326
- let arity = Ctype. arity ty in
1340
+ let arity = customize_arity ( Ctype. arity ty) valdecl.pval_attributes in
1327
1341
let prim = Primitive. parse_declaration arity decl in
1328
1342
let prim_native_name = prim.prim_native_name in
1329
1343
if arity = 0 && not ( String. length prim_native_name > 3 &&
You can’t perform that action at this time.
0 commit comments