Report duplicate names with a good error message

Indicate which name is duplicated in which jbuild files
This commit is contained in:
Rudi Grinberg 2017-10-20 11:08:42 +08:00
parent a63276f5b3
commit bfc83d71d7
1 changed files with 9 additions and 1 deletions

View File

@ -123,7 +123,15 @@ let create findlib ~dirs_with_dot_opam_files internal_libraries =
let scope = internal_name_scope t ~dir in
scope := String_map.add !scope ~key:lib.Library.name ~data:internal;
Option.iter lib.public ~f:(fun { name; _ } ->
Hashtbl.add t.by_public_name ~key:name ~data:(Internal internal)));
match Hashtbl.find t.by_public_name name with
| None
| Some (External _) ->
Hashtbl.add t.by_public_name ~key:name ~data:(Internal internal)
| Some (Internal dup) ->
let internal_path (path, _) = Path.relative path "jbuild" in
die "Libraries with identical public names %s defined in %a and %a."
name Path.pp (internal_path internal) Path.pp (internal_path dup)
));
compute_instalable_internal_libs t ~internal_libraries
let internal_libs_without_non_installable_optional_ones t =