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 =
13131313 let newenv = Env. add_extension ~check: true ext.ext_id ext.ext_type env in
13141314 ext, newenv
13151315
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+
13161330(* Translate a value declaration *)
13171331let transl_value_decl env loc valdecl =
13181332 let cty = Typetexp. transl_type_scheme env valdecl.pval_type in
@@ -1323,7 +1337,7 @@ let transl_value_decl env loc valdecl =
13231337 { val_type = ty; val_kind = Val_reg ; Types. val_loc = loc;
13241338 val_attributes = valdecl.pval_attributes }
13251339 | decl ->
1326- let arity = Ctype. arity ty in
1340+ let arity = customize_arity ( Ctype. arity ty) valdecl.pval_attributes in
13271341 let prim = Primitive. parse_declaration arity decl in
13281342 let prim_native_name = prim.prim_native_name in
13291343 if arity = 0 && not ( String. length prim_native_name > 3 &&
You can’t perform that action at this time.
0 commit comments