Skip to content

Commit 965b7cf

Browse files
committed
Only print warning number
1 parent 32bd838 commit 965b7cf

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/lib/uTop_main.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,21 +1393,20 @@ let print_version_num () =
13931393
module Test = struct
13941394
let map_loc f {Location.loc;txt} = {Location.loc; txt= f txt}
13951395

1396+
let shorten_warning_name s =
1397+
Scanf.sscanf s "%d" string_of_int
1398+
13961399
let shorten_kind = function
1397-
| Location.Report_error -> Location.Report_error
1398-
| Report_warning _ -> Report_warning "A"
1399-
| Report_warning_as_error _ -> Report_warning_as_error "B"
1400-
| Report_alert _ -> Report_alert "C"
1401-
| Report_alert_as_error _ -> Report_alert "D"
1400+
| Location.Report_warning s -> Location.Report_warning (shorten_warning_name s)
1401+
| k -> k
14021402

14031403
let short_warning_reporter loc warn =
14041404
Option.map
1405-
(fun report ->
1406-
{ report with Location.main = Location.mknoloc (fun _ -> ())
1407-
; kind = shorten_kind report.Location.kind
1408-
}
1409-
)
1410-
(Location.default_warning_reporter loc warn)
1405+
(fun report ->
1406+
{ report with
1407+
Location.kind = shorten_kind report.Location.kind }
1408+
)
1409+
(Location.default_warning_reporter loc warn)
14111410

14121411
let short_report_printer () =
14131412
let def = Location.batch_mode_printer in
@@ -1417,6 +1416,7 @@ module Test = struct
14171416
{ def with pp }
14181417

14191418
let setup () =
1419+
Location.warning_reporter := short_warning_reporter;
14201420
Location.report_printer := short_report_printer
14211421

14221422
let run path =

test/demo.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# type t = () of unit;;
2-
Warning 65 [redefining-unit]
2+
Warning 65
33
type t = () of unit
44
# 0;;
55
Error

0 commit comments

Comments
 (0)