@@ -409500,9 +409500,7 @@ module Super_misc : sig
409500409500#1 "super_misc.mli"
409501409501(** Range coordinates all 1-indexed, like for editors. Otherwise this code
409502409502 would have way too many off-by-one errors *)
409503- val print_file:
409504- range:(int * int) * (int * int) ->
409505- lines:string array -> Format.formatter -> unit -> unit
409503+ val print_file: is_warning:bool -> range:(int * int) * (int * int) -> lines:string array -> Format.formatter -> unit -> unit
409506409504
409507409505end = struct
409508409506#1 "super_misc.ml"
@@ -409544,7 +409542,7 @@ type current_printed_line_status =
409544409542(* Range coordinates all 1-indexed, like for editors. Otherwise this code
409545409543 would have way too many off-by-one errors *)
409546409544let print_file
409547-
409545+ ~is_warning
409548409546(* start_line_start_char inclusive, end_line_end_char exclusive *)
409549409547~range:((start_line, start_line_start_char), (end_line, end_line_end_char))
409550409548~lines
@@ -409577,10 +409575,10 @@ ppf
409577409575 | Some n -> n
409578409576 in
409579409577 (* coloring *)
409580- let highlighted_line_number : _ format = "@{<error>%s@}%a" in
409578+ let highlighted_line_number : _ format = if is_warning then "@{<info>%s@}%a" else "@{<error>%s@}%a" in
409581409579
409582409580 let print_char_maybe_highlight ~begin_highlight_line ~end_highlight_line ch =
409583- let highlighted_open_tag: _ format = "@{<error>" in
409581+ let highlighted_open_tag: _ format = if is_warning then "@{<info>" else "@{<error>" in
409584409582 if begin_highlight_line then fprintf ppf highlighted_open_tag;
409585409583 fprintf ppf "%c@," ch;
409586409584 if end_highlight_line then fprintf ppf "@}"
@@ -409721,8 +409719,12 @@ let print_loc ~normalizedRange ppf (loc : Location.t) =
409721409719 fprintf ppf "@{<filename>%a@}%a" print_filename loc.loc_start.pos_fname dim_loc normalizedRange
409722409720;;
409723409721
409724- let print intro ppf (loc : Location.t) =
409725- fprintf ppf "@[@{<error>%s@}@]@," intro;
409722+ let print ~message_kind intro ppf (loc : Location.t) =
409723+ begin match message_kind with
409724+ | `warning -> fprintf ppf "@[@{<info>%s@}@]@," intro
409725+ | `warning_as_error -> fprintf ppf "@[@{<error>%s@} (configured as error) @]@," intro
409726+ | `error -> fprintf ppf "@[@{<error>%s@}@]@," intro
409727+ end;
409726409728 (* ocaml's reported line/col numbering is horrible and super error-prone
409727409729 when being handled programmatically (or humanly for that matter. If you're
409728409730 an ocaml contributor reading this: who the heck reads the character count
@@ -409756,7 +409758,7 @@ let print intro ppf (loc : Location.t) =
409756409758 branch might not be reached (aka no inline file content display) so
409757409759 we don't wanna end up with two line breaks in the the consequent *)
409758409760 fprintf ppf "@,%a"
409759- (Super_misc.print_file ~lines ~range)
409761+ (Super_misc.print_file ~is_warning:(message_kind=`warning) ~lines ~range)
409760409762 ()
409761409763 with
409762409764 (* this might happen if the file is e.g. "", "_none_" or any of the fake file name placeholders.
@@ -409770,7 +409772,7 @@ let print intro ppf (loc : Location.t) =
409770409772let rec super_error_reporter ppf ({loc; msg; sub} : Location.error) =
409771409773 setup_colors ();
409772409774 (* open a vertical box. Everything in our message is indented 2 spaces *)
409773- Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]" (print "We've found a bug for you!") loc msg;
409775+ Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]" (print ~message_kind:`error "We've found a bug for you!") loc msg;
409774409776 List.iter (Format.fprintf ppf "@,@[%a@]" super_error_reporter) sub
409775409777 (* no need to flush here; location's report_exception (which uses this ultimately) flushes *)
409776409778
@@ -409780,10 +409782,11 @@ let rec super_error_reporter ppf ({loc; msg; sub} : Location.error) =
409780409782let super_warning_printer loc ppf w =
409781409783 match Warnings.report w with
409782409784 | `Inactive -> ()
409783- | `Active { Warnings. number = _; message = _; sub_locs = _} ->
409785+ | `Active { Warnings. number = _; message = _; is_error; sub_locs = _} ->
409784409786 setup_colors ();
409785- Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]@."
409786- (print ("Warning number " ^ (Warnings.number w |> string_of_int)))
409787+ let message_kind = if is_error then `warning_as_error else `warning in
409788+ Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]"
409789+ (print ~message_kind ("Warning number " ^ (Warnings.number w |> string_of_int)))
409787409790 loc
409788409791 (Warnings.message w);
409789409792 (* at this point, you can display sub_locs too, from e.g. https://github.com/ocaml/ocaml/commit/f6d53cc38f87c67fbf49109f5fb79a0334bab17a
0 commit comments