@@ -1913,9 +1913,12 @@ let rec approx_type env sty =
19131913let  rec  type_approx  env  sexp  = 
19141914  match  sexp.pexp_desc with  
19151915  |  Pexp_let  (_ , _ , e ) -> type_approx env e 
1916-   |  Pexp_fun  (p , _ , _ , e , _arity ) -> 
1916+   |  Pexp_fun  (p , _ , _ , e , arity ) -> (  
19171917    let  ty =  if  is_optional p then  type_option (newvar () ) else  newvar ()  in  
1918-     newty (Tarrow  (p, ty, type_approx env e, Cok )) 
1918+     let  t =  newty (Tarrow  (p, ty, type_approx env e, Cok )) in  
1919+     match  arity with  
1920+     |  None  -> t 
1921+     |  Some  arity  -> Ast_uncurried. make_uncurried_type ~env  ~arity  t) 
19191922  |  Pexp_match  (_ , {pc_rhs  = e }  :: _ ) -> type_approx env e 
19201923  |  Pexp_try  (e , _ ) -> type_approx env e 
19211924  |  Pexp_tuple  l  -> newty (Ttuple  (List. map (type_approx env) l)) 
@@ -2525,25 +2528,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp
25252528        exp_attributes =  sexp.pexp_attributes; 
25262529        exp_env =  env; 
25272530      } 
2528-   |  Pexp_construct  
2529-       ( ({txt =  Lident  " Function$"  } as  lid), 
2530-         (Some  {pexp_desc =  Pexp_fun  (_, _, _, _, Some  arity)} as  sarg) ) -> 
2531-     let  state =  Warnings. backup ()  in  
2532-     let  uncurried_typ =  
2533-       Ast_uncurried. make_uncurried_type ~env  ~arity  (newvar () ) 
2534-     in  
2535-     unify_exp_types loc env uncurried_typ ty_expected; 
2536-     (*  Disable Unerasable_optional_argument for uncurried functions *)  
2537-     let  unerasable_optional_argument =  
2538-       Warnings. number Unerasable_optional_argument  
2539-     in  
2540-     Warnings. parse_options false  
2541-       (" -"   ^  string_of_int unerasable_optional_argument); 
2542-     let  exp =  
2543-       type_construct env loc lid sarg uncurried_typ sexp.pexp_attributes 
2544-     in  
2545-     Warnings. restore state; 
2546-     exp 
25472531  |  Pexp_construct  (lid , sarg ) -> 
25482532    type_construct env loc lid sarg ty_expected sexp.pexp_attributes 
25492533  |  Pexp_variant  (l , sarg ) -> ( 
@@ -3273,7 +3257,22 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp
32733257  |  Pexp_extension  ext  -> 
32743258    raise (Error_forward  (Builtin_attributes. error_of_extension ext)) 
32753259
3276- and  type_function  ?in_function   ~arity   loc  attrs  env  ty_expected  l  caselist  = 
3260+ and  type_function  ?in_function   ~arity   loc  attrs  env  ty_expected_  l  caselist  = 
3261+   let  state =  Warnings. backup ()  in  
3262+   (*  Disable Unerasable_optional_argument for uncurried functions *)  
3263+   let  unerasable_optional_argument =  
3264+     Warnings. number Unerasable_optional_argument  
3265+   in  
3266+   Warnings. parse_options false  (" -"   ^  string_of_int unerasable_optional_argument); 
3267+   let  ty_expected =  
3268+     match  arity with  
3269+     |  None  -> ty_expected_ 
3270+     |  Some  arity  -> 
3271+       let  fun_t =  newvar ()  in  
3272+       let  uncurried_typ =  Ast_uncurried. make_uncurried_type ~env  ~arity  fun_t in  
3273+       unify_exp_types loc env uncurried_typ ty_expected_; 
3274+       fun_t 
3275+   in  
32773276  let  loc_fun, ty_fun =  
32783277    match  in_function with  
32793278    |  Some  p  -> p 
@@ -3311,12 +3310,19 @@ and type_function ?in_function ~arity loc attrs env ty_expected l caselist =
33113310    Location. prerr_warning case.c_lhs.pat_loc 
33123311      Warnings. Unerasable_optional_argument ; 
33133312  let  param =  name_pattern " param"   cases in  
3313+   let  exp_type =  instance env (newgenty (Tarrow  (l, ty_arg, ty_res, Cok ))) in  
3314+   let  exp_type =  
3315+     match  arity with  
3316+     |  None  -> exp_type 
3317+     |  Some  arity  -> Ast_uncurried. make_uncurried_type ~env  ~arity  exp_type 
3318+   in  
3319+   Warnings. restore state; 
33143320  re 
33153321    { 
33163322      exp_desc =  Texp_function  {arg_label =  l; arity; param; case; partial}; 
33173323      exp_loc =  loc; 
33183324      exp_extra =  [] ; 
3319-       exp_type  =  instance env (newgenty ( Tarrow  (l, ty_arg, ty_res,  Cok ))) ; 
3325+       exp_type; 
33203326      exp_attributes =  attrs; 
33213327      exp_env =  env; 
33223328    } 
0 commit comments