@@ -4,7 +4,7 @@ open Cmi_format;
44
55type error =
66 | Missing_module (Location . t , Path . t , Path . t )
7- | No_module_file (string , option (string ));
7+ | No_module_file (Location . t , string , option (string ));
88
99exception Error ( error) ;
1010
@@ -280,16 +280,32 @@ module Dependency_graph =
280280 let from_srcpath = srcpath => {
281281 List . map(
282282 name => {
283- let located = locate_module(base_dir, active_search_path, name);
283+ let located =
284+ try (
285+ locate_module(
286+ base_dir,
287+ active_search_path,
288+ name. Location . txt,
289+ )
290+ ) {
291+ | Not_found =>
292+ error(
293+ No_module_file (
294+ name. Location . loc,
295+ name. Location . txt,
296+ None ,
297+ ),
298+ )
299+ };
284300 let out_file_name = located_to_out_file_name(located);
285301 let existing_dependency = lookup(out_file_name);
286302 switch (existing_dependency) {
287303 | Some (ed ) =>
288- Hashtbl . add(ed. dn_unit_name, Some (dn), name);
304+ Hashtbl . add(ed. dn_unit_name, Some (dn), name. Location . txt );
289305 ed;
290306 | None =>
291307 let tbl = Hashtbl . create(8 );
292- Hashtbl . add(tbl, Some (dn), name);
308+ Hashtbl . add(tbl, Some (dn), name. Location . txt );
293309 {
294310 dn_unit_name: tbl,
295311 dn_file_name: out_file_name,
@@ -315,7 +331,16 @@ module Dependency_graph =
315331 List . map(
316332 ((name, _)) => {
317333 let located =
318- locate_module(base_dir, active_search_path, name);
334+ try (locate_module(base_dir, active_search_path, name)) {
335+ | Not_found =>
336+ error(
337+ No_module_file (
338+ Location . in_file(dn. dn_file_name),
339+ name,
340+ None ,
341+ ),
342+ )
343+ };
319344 let out_file_name = located_to_out_file_name(located);
320345 let existing_dependency = lookup(out_file_name);
321346 switch (existing_dependency) {
@@ -435,7 +460,7 @@ let locate_module_file = (~loc, ~disable_relpath=false, unit_name) => {
435460 let path = Config . module_search_path() ;
436461 let located =
437462 try (locate_module(~disable_relpath, base_dir, path, unit_name)) {
438- | Not_found => error(No_module_file (unit_name, None ))
463+ | Not_found => error(No_module_file (loc , unit_name, None ))
439464 };
440465 let out_file = located_to_out_file_name(located);
441466 let current_dep_node =
@@ -509,14 +534,16 @@ let report_error = ppf =>
509534 "was not found" ,
510535 );
511536 }
512- | No_module_file (m , None ) => fprintf (ppf, "Missing file for module % s " , m)
513- | No_module_file (m , Some (msg )) =>
537+ | No_module_file (_ , m , None ) =>
538+ fprintf (ppf, "Missing file for module % s " , m)
539+ | No_module_file (_ , m , Some (msg )) =>
514540 fprintf (ppf, "Missing file for module % s : % s " , m, msg);
515541
516542let () =
517543 Location . register_error_of_exn(
518544 fun
519- | Error (Missing_module (loc , _ , _ ) as err ) when loc != Location . dummy_loc =>
545+ | Error (Missing_module (loc , _ , _ ) as err )
546+ | Error (No_module_file (loc , _ , _ ) as err ) when loc != Location . dummy_loc =>
520547 Some (Location . error_of_printer(loc, report_error, err))
521548 | Error (err ) => Some (Location . error_of_printer_file(report_error, err))
522549 | _ => None ,
0 commit comments