@@ -3798,7 +3798,13 @@ let spellcheck_idents ppf unbound valid_idents =
3798
3798
spellcheck ppf (Ident. name unbound) (List. map Ident. name valid_idents)
3799
3799
3800
3800
open Format
3801
- open Printtyp
3801
+ let longident = Printtyp. longident
3802
+ let super_report_unification_error = Printtyp. super_report_unification_error
3803
+ let report_ambiguous_type_error = Printtyp. report_ambiguous_type_error
3804
+ let report_subtyping_error = Printtyp. report_subtyping_error
3805
+ let type_expr ppf typ = (* print a type and avoid infinite loops *)
3806
+ Printtyp. reset_and_mark_loops typ;
3807
+ Printtyp. type_expr ppf typ
3802
3808
3803
3809
let report_error env ppf = function
3804
3810
| Polymorphic_label lid ->
@@ -3867,7 +3873,6 @@ let report_error env ppf = function
3867
3873
fprintf ppf " @]"
3868
3874
| Apply_non_function typ ->
3869
3875
(* modified *)
3870
- reset_and_mark_loops typ;
3871
3876
begin match (repr typ).desc with
3872
3877
Tarrow (_ , _inputType , returnType , _ ) ->
3873
3878
let rec countNumberOfArgs count {Types. desc} = match desc with
@@ -3891,7 +3896,6 @@ let report_error env ppf = function
3891
3896
| l ->
3892
3897
fprintf ppf " with label %s" (prefixed_label_name l)
3893
3898
in
3894
- reset_and_mark_loops ty;
3895
3899
fprintf ppf
3896
3900
" @[<v>@[<2>The function applied to this argument has type@ %a@]@.\
3897
3901
This argument cannot be applied %a@]"
@@ -3908,7 +3912,6 @@ let report_error env ppf = function
3908
3912
fprintf ppf " The record field %a is not mutable" longident lid
3909
3913
| Wrong_name (eorp , ty , kind , p , name , valid_names ) ->
3910
3914
(* modified *)
3911
- reset_and_mark_loops ty;
3912
3915
if Path. is_constructor_typath p then begin
3913
3916
fprintf ppf " @[The field %s is not part of the record \
3914
3917
argument for the %a constructor@]"
@@ -3940,7 +3943,6 @@ let report_error env ppf = function
3940
3943
fprintf ppf " but a %s was expected belonging to the %s type"
3941
3944
name kind)
3942
3945
| Undefined_method (ty , me , valid_methods ) ->
3943
- reset_and_mark_loops ty;
3944
3946
fprintf ppf
3945
3947
" @[<v>@[This expression has type@;<1 2>%a@]@,\
3946
3948
It has no field %s@]" type_expr ty me;
@@ -3966,7 +3968,6 @@ let report_error env ppf = function
3966
3968
" Consider using a double coercion."
3967
3969
| Too_many_arguments (in_function , ty ) ->
3968
3970
(* modified *)
3969
- reset_and_mark_loops ty;
3970
3971
if in_function then begin
3971
3972
fprintf ppf " @[This function expects too many arguments,@ " ;
3972
3973
fprintf ppf " it should have type@ %a@]"
@@ -3985,11 +3986,9 @@ let report_error env ppf = function
3985
3986
| Nolabel -> " but its first argument is not labelled"
3986
3987
| l -> sprintf " but its first argument is labelled %s"
3987
3988
(prefixed_label_name l) in
3988
- reset_and_mark_loops ty;
3989
3989
fprintf ppf " @[<v>@[<2>This function should have type@ %a@]@,%s@]"
3990
3990
type_expr ty (label_mark l)
3991
3991
| Scoping_let_module (id , ty ) ->
3992
- reset_and_mark_loops ty;
3993
3992
fprintf ppf
3994
3993
" This `let module' expression has type@ %a@ " type_expr ty;
3995
3994
fprintf ppf
@@ -4031,7 +4030,7 @@ let report_error env ppf = function
4031
4030
" Unexpected existential"
4032
4031
| Unqualified_gadt_pattern (tpath , name ) ->
4033
4032
fprintf ppf " @[The GADT constructor %s of type %a@ %s.@]"
4034
- name path tpath
4033
+ name Printtyp. path tpath
4035
4034
" must be qualified in this pattern"
4036
4035
| Invalid_interval ->
4037
4036
fprintf ppf " @[Only character intervals are supported in patterns.@]"
@@ -4082,20 +4081,20 @@ let report_error env ppf = function
4082
4081
fprintf ppf " Empty record literal {} should be type annotated or used in a record context."
4083
4082
| Uncurried_arity_mismatch (typ , arity , args ) ->
4084
4083
fprintf ppf " @[<v>@[<2>This uncurried function has type@ %a@]"
4085
- type_expr typ;
4084
+ type_expr typ;
4086
4085
fprintf ppf " @ @[It is applied with @{<error>%d@} argument%s but it requires @{<info>%d@}.@]@]"
4087
4086
args (if args = 0 then " " else " s" ) arity
4088
4087
| Field_not_optional (name , typ ) ->
4089
4088
fprintf ppf
4090
- " Field @{<info>%s@} is not optional in type %a. Use without ?" name
4091
- type_expr typ
4089
+ " Field @{<info>%s@} is not optional in type %a. Use without ?" name
4090
+ type_expr typ
4092
4091
4093
4092
4094
4093
let super_report_error_no_wrap_printing_env = report_error
4095
4094
4096
4095
4097
4096
let report_error env ppf err =
4098
- wrap_printing_env env (fun () -> report_error env ppf err)
4097
+ Printtyp. wrap_printing_env env (fun () -> report_error env ppf err)
4099
4098
4100
4099
let () =
4101
4100
Location. register_error_of_exn
0 commit comments