@@ -3757,7 +3757,13 @@ let spellcheck_idents ppf unbound valid_idents =
3757
3757
spellcheck ppf (Ident. name unbound) (List. map Ident. name valid_idents)
3758
3758
3759
3759
open Format
3760
- open Printtyp
3760
+ let longident = Printtyp. longident
3761
+ let super_report_unification_error = Printtyp. super_report_unification_error
3762
+ let report_ambiguous_type_error = Printtyp. report_ambiguous_type_error
3763
+ let report_subtyping_error = Printtyp. report_subtyping_error
3764
+ let type_expr ppf typ = (* print a type and avoid infinite loops *)
3765
+ Printtyp. reset_and_mark_loops typ;
3766
+ Printtyp. type_expr ppf typ
3761
3767
3762
3768
let report_error env ppf = function
3763
3769
| Polymorphic_label lid ->
@@ -3826,7 +3832,6 @@ let report_error env ppf = function
3826
3832
fprintf ppf " @]"
3827
3833
| Apply_non_function typ ->
3828
3834
(* modified *)
3829
- reset_and_mark_loops typ;
3830
3835
begin match (repr typ).desc with
3831
3836
Tarrow (_ , _inputType , return_type , _ ) ->
3832
3837
let rec count_number_of_args count {Types. desc} = match desc with
@@ -3850,7 +3855,6 @@ let report_error env ppf = function
3850
3855
| l ->
3851
3856
fprintf ppf " with label %s" (prefixed_label_name l)
3852
3857
in
3853
- reset_and_mark_loops ty;
3854
3858
fprintf ppf
3855
3859
" @[<v>@[<2>The function applied to this argument has type@ %a@]@.\
3856
3860
This argument cannot be applied %a@]"
@@ -3867,7 +3871,6 @@ let report_error env ppf = function
3867
3871
fprintf ppf " The record field %a is not mutable" longident lid
3868
3872
| Wrong_name (eorp , ty , kind , p , name , valid_names ) ->
3869
3873
(* modified *)
3870
- reset_and_mark_loops ty;
3871
3874
if Path. is_constructor_typath p then begin
3872
3875
fprintf ppf " @[The field %s is not part of the record \
3873
3876
argument for the %a constructor@]"
@@ -3899,7 +3902,6 @@ let report_error env ppf = function
3899
3902
fprintf ppf " but a %s was expected belonging to the %s type"
3900
3903
name kind)
3901
3904
| Undefined_method (ty , me , valid_methods ) ->
3902
- reset_and_mark_loops ty;
3903
3905
fprintf ppf
3904
3906
" @[<v>@[This expression has type@;<1 2>%a@]@,\
3905
3907
It has no field %s@]" type_expr ty me;
@@ -3911,7 +3913,6 @@ let report_error env ppf = function
3911
3913
report_subtyping_error ppf env tr1 " is not a subtype of" tr2
3912
3914
| Too_many_arguments (in_function , ty ) ->
3913
3915
(* modified *)
3914
- reset_and_mark_loops ty;
3915
3916
if in_function then begin
3916
3917
fprintf ppf " @[This function expects too many arguments,@ " ;
3917
3918
fprintf ppf " it should have type@ %a@]"
@@ -3930,11 +3931,9 @@ let report_error env ppf = function
3930
3931
| Nolabel -> " but its first argument is not labelled"
3931
3932
| l -> sprintf " but its first argument is labelled %s"
3932
3933
(prefixed_label_name l) in
3933
- reset_and_mark_loops ty;
3934
3934
fprintf ppf " @[<v>@[<2>This function should have type@ %a@]@,%s@]"
3935
3935
type_expr ty (label_mark l)
3936
3936
| Scoping_let_module (id , ty ) ->
3937
- reset_and_mark_loops ty;
3938
3937
fprintf ppf
3939
3938
" This `let module' expression has type@ %a@ " type_expr ty;
3940
3939
fprintf ppf
@@ -3976,7 +3975,7 @@ let report_error env ppf = function
3976
3975
" Unexpected existential"
3977
3976
| Unqualified_gadt_pattern (tpath , name ) ->
3978
3977
fprintf ppf " @[The GADT constructor %s of type %a@ %s.@]"
3979
- name path tpath
3978
+ name Printtyp. path tpath
3980
3979
" must be qualified in this pattern"
3981
3980
| Invalid_interval ->
3982
3981
fprintf ppf " @[Only character intervals are supported in patterns.@]"
@@ -4027,20 +4026,20 @@ let report_error env ppf = function
4027
4026
fprintf ppf " Empty record literal {} should be type annotated or used in a record context."
4028
4027
| Uncurried_arity_mismatch (typ , arity , args ) ->
4029
4028
fprintf ppf " @[<v>@[<2>This uncurried function has type@ %a@]"
4030
- type_expr typ;
4029
+ type_expr typ;
4031
4030
fprintf ppf " @ @[It is applied with @{<error>%d@} argument%s but it requires @{<info>%d@}.@]@]"
4032
4031
args (if args = 0 then " " else " s" ) arity
4033
4032
| Field_not_optional (name , typ ) ->
4034
4033
fprintf ppf
4035
- " Field @{<info>%s@} is not optional in type %a. Use without ?" name
4036
- type_expr typ
4034
+ " Field @{<info>%s@} is not optional in type %a. Use without ?" name
4035
+ type_expr typ
4037
4036
4038
4037
4039
4038
let super_report_error_no_wrap_printing_env = report_error
4040
4039
4041
4040
4042
4041
let report_error env ppf err =
4043
- wrap_printing_env env (fun () -> report_error env ppf err)
4042
+ Printtyp. wrap_printing_env env (fun () -> report_error env ppf err)
4044
4043
4045
4044
let () =
4046
4045
Location. register_error_of_exn
0 commit comments