Skip to content

Commit

Permalink
Only print warning number
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Feb 24, 2023
1 parent a3ad367 commit 2f56c83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/lib/uTop_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,21 +1410,20 @@ let print_version_num () =
module Test = struct
let map_loc f {Location.loc;txt} = {Location.loc; txt= f txt}

let shorten_warning_name s =
Scanf.sscanf s "%d" string_of_int

let shorten_kind = function
| Location.Report_error -> Location.Report_error
| Report_warning _ -> Report_warning "A"
| Report_warning_as_error _ -> Report_warning_as_error "B"
| Report_alert _ -> Report_alert "C"
| Report_alert_as_error _ -> Report_alert "D"
| Location.Report_warning s -> Location.Report_warning (shorten_warning_name s)
| k -> k

let short_warning_reporter loc warn =
Option.map
(fun report ->
{ report with Location.main = Location.mknoloc (fun _ -> ())
; kind = shorten_kind report.Location.kind
}
)
(Location.default_warning_reporter loc warn)
(fun report ->
{ report with
Location.kind = shorten_kind report.Location.kind }
)
(Location.default_warning_reporter loc warn)

let short_report_printer () =
let def = Location.batch_mode_printer in
Expand All @@ -1434,6 +1433,7 @@ module Test = struct
{ def with pp }

let setup () =
Location.warning_reporter := short_warning_reporter;
Location.report_printer := short_report_printer

let run path =
Expand Down
2 changes: 1 addition & 1 deletion test/demo.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# type t = () of unit;;
Warning 65 [redefining-unit]
Warning 65
type t = () of unit
# 0;;
Error

0 comments on commit 2f56c83

Please sign in to comment.