Skip to content

Commit 169fed3

Browse files
committed
better location for ocaml#4513
1 parent 729bff3 commit 169fed3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

typing/includemod.ml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,30 @@ let report_error ppf errs =
681681
fprintf ppf "@[<v>%a%a@]" print_errs errs include_err err
682682

683683

684+
let better_candidate_loc (x : error list) =
685+
match x with
686+
| [ (_,_,Interface_mismatch _); (_,_,descr)]
687+
->
688+
begin match descr with
689+
| Value_descriptions (_,d1,_) -> Some d1.val_loc
690+
| Type_declarations (_,tdcl1,_,_) ->
691+
Some tdcl1.type_loc
692+
| Missing_field (_,loc,_) -> Some loc
693+
| _ -> None
694+
end
695+
| _ -> None
696+
684697
(* We could do a better job to split the individual error items
685698
as sub-messages of the main interface mismatch on the whole unit. *)
686699
let () =
687700
Location.register_error_of_exn
688701
(function
689-
| Error err -> Some (Location.error_of_printer_file report_error err)
702+
| Error err ->
703+
begin match better_candidate_loc err with
704+
| None ->
705+
Some (Location.error_of_printer_file report_error err)
706+
| Some loc ->
707+
Some (Location.error_of_printer loc report_error err)
708+
end
690709
| _ -> None
691710
)

0 commit comments

Comments
 (0)