@@ -26,7 +26,12 @@ open Error_message_utils
2626
2727type  error  =
2828  | Polymorphic_label  of  Longident .t 
29-   | Constructor_arity_mismatch  of  Longident .t  *  int  *  int 
29+   | Constructor_arity_mismatch  of  {
30+       name : Longident .t ; 
31+       constuctor : constructor_description ; 
32+       expected : int ; 
33+       provided : int ; 
34+     }
3035  | Label_mismatch  of  Longident .t  *  (type_expr  *  type_expr ) list 
3136  | Pattern_type_clash  of  (type_expr  *  type_expr ) list 
3237  | Or_pattern_type_clash  of  Ident .t  *  (type_expr  *  type_expr ) list 
@@ -1400,7 +1405,12 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env sp
14001405           ( loc, 
14011406             ! env, 
14021407             Constructor_arity_mismatch  
1403-                (lid.txt, constr.cstr_arity, List. length sargs) )); 
1408+                { 
1409+                  name =  lid.txt; 
1410+                  constuctor =  constr; 
1411+                  expected =  constr.cstr_arity; 
1412+                  provided =  List. length sargs; 
1413+                } )); 
14041414    let  ty_args, ty_res =  
14051415      instance_constructor ~in_pattern: (env, get_newtype_level () ) constr 
14061416    in  
@@ -3758,7 +3768,12 @@ and type_construct ~context env loc lid sarg ty_expected attrs =
37583768         ( loc, 
37593769           env, 
37603770           Constructor_arity_mismatch  
3761-              (lid.txt, constr.cstr_arity, List. length sargs) )); 
3771+              { 
3772+                name =  lid.txt; 
3773+                constuctor =  constr; 
3774+                expected =  constr.cstr_arity; 
3775+                provided =  List. length sargs; 
3776+              } )); 
37623777  let  separate =  Env. has_local_constraints env in  
37633778  if  separate then  ( 
37643779    begin_def () ; 
@@ -4295,14 +4310,24 @@ let report_error env loc ppf error =
42954310  |  Polymorphic_label  lid  -> 
42964311    fprintf ppf " @[The record field %a is polymorphic.@ %s@]"  
42974312      " You cannot instantiate it in a pattern."  
4298-   |  Constructor_arity_mismatch  ( lid ,  expected ,  provided )  -> 
4313+   |  Constructor_arity_mismatch  {name; constuctor;  expected;  provided}  
42994314    (*  modified *)  
4300-     fprintf ppf 
4301-       " @[This variant constructor, %a, expects %i %s; here, we've %sfound %i.@]"  
4302-       longident lid expected 
4303-       (if  expected ==  1  then  " argument" else  " arguments"  
4304-       (if  provided <  expected then  " only " else  " "  
4305-       provided 
4315+     let  is_inline_record =  Option. is_some constuctor.cstr_inlined in  
4316+     if  is_inline_record &&  expected =  1  then  
4317+       fprintf ppf 
4318+         " @[This variant constructor @{<info>%a@} expects an inline record as \ 
4319+          payload%s.@]"  
4320+         longident name 
4321+         (if  provided =  0  then  " , but it's not being passed any arguments"  
4322+          else  " "  
4323+     else  
4324+       fprintf ppf 
4325+         " @[This variant constructor @{<info>%a@} expects %i %s, but it's%s \ 
4326+          being passed %i.@]"  
4327+         longident name expected 
4328+         (if  expected ==  1  then  " argument" else  " arguments"  
4329+         (if  provided <  expected then  "  only" else  " "  
4330+         provided 
43064331  |  Label_mismatch  (lid , trace ) -> 
43074332    (*  modified *)  
43084333    super_report_unification_error ppf env trace 
0 commit comments