Skip to content

Commit 3f3c527

Browse files
authored
Merge pull request #1929 from chenglou/fix-printtyp
[Super errors] Restore normal unification printing if -bs-super-errors isn't passed
2 parents 80f774d + 52e8e4d commit 3f3c527

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

vendor/ocaml/typing/printtyp.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,6 @@ let rec trace_same_names = function
14291429
type_same_name t1 t2; type_same_name t1' t2'; trace_same_names rem
14301430
| _ -> ()
14311431

1432-
#if defined BS_NO_COMPILER_PATCH then
14331432
let unification_error unif tr txt1 ppf txt2 =
14341433
reset ();
14351434
trace_same_names tr;
@@ -1458,7 +1457,13 @@ let unification_error unif tr txt1 ppf txt2 =
14581457
with exn ->
14591458
print_labels := true;
14601459
raise exn
1461-
#else
1460+
1461+
let report_unification_error ppf env ?(unif=true)
1462+
tr txt1 txt2 =
1463+
wrap_printing_env env (fun () -> unification_error unif tr txt1 ppf txt2)
1464+
;;
1465+
1466+
#if undefined BS_NO_COMPILER_PATCH then
14621467
let super_type_expansion ~tag t ppf t' =
14631468
if same_path t t' then begin
14641469
Format.pp_open_tag ppf tag;
@@ -1502,7 +1507,7 @@ let super_trace ppf =
15021507
| _ -> ()
15031508
in super_trace true ppf
15041509

1505-
let unification_error unif tr txt1 ppf txt2 = begin
1510+
let super_unification_error unif tr txt1 ppf txt2 = begin
15061511
reset ();
15071512
trace_same_names tr;
15081513
let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in
@@ -1538,12 +1543,12 @@ let unification_error unif tr txt1 ppf txt2 = begin
15381543
print_labels := true;
15391544
raise exn
15401545
end
1541-
#end
15421546

1543-
let report_unification_error ppf env ?(unif=true)
1547+
let super_report_unification_error ppf env ?(unif=true)
15441548
tr txt1 txt2 =
1545-
wrap_printing_env env (fun () -> unification_error unif tr txt1 ppf txt2)
1549+
wrap_printing_env env (fun () -> super_unification_error unif tr txt1 ppf txt2)
15461550
;;
1551+
#end
15471552

15481553
let trace fst keep_last txt ppf tr =
15491554
print_labels := not !Clflags.classic;

vendor/ocaml/typing/printtyp.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ val report_unification_error:
7272
formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list ->
7373
(formatter -> unit) -> (formatter -> unit) ->
7474
unit
75+
76+
#if undefined BS_NO_COMPILER_PATCH then
77+
val super_report_unification_error:
78+
formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list ->
79+
(formatter -> unit) -> (formatter -> unit) ->
80+
unit
81+
#end
82+
7583
val report_subtyping_error:
7684
formatter -> Env.t -> (type_expr * type_expr) list ->
7785
string -> (type_expr * type_expr) list -> unit

0 commit comments

Comments
 (0)