Fix #661: better error when a public library is defined twice

This commit is contained in:
Jeremie Dimino 2018-03-29 15:04:14 -04:00
parent fb101857d4
commit c7b9c2cd3e
2 changed files with 22 additions and 2 deletions

View File

@ -34,7 +34,10 @@ next
- Fix a regression introduced by beta19 where the generated merlin
files didn't include the right `-ppx` flags in some cases (#658
fixess #657 @diml)
fixes #657 @diml)
- Fix error messaage when a public library is defined twice. Before
jbuilder would raise an uncaught exception (Fixes #661, @diml)
1.0+beta19.1 (21/03/2018)
-------------------------

View File

@ -77,7 +77,24 @@ module DB = struct
match lib.public with
| None -> None
| Some p -> Some (p.name, lib.scope_name))
|> String_map.of_list_exn
|> String_map.of_list
|> function
| Ok x -> x
| Error (name, _, _) ->
match
List.filter_map internal_libs ~f:(fun (_dir, lib) ->
match lib.public with
| None -> None
| Some p -> Option.some_if (name = p.name) lib.buildable.loc)
with
| [] | [_] -> assert false
| loc1 :: loc2 :: _ ->
die "Public library %S is defined twice:\n\
- %s\n\
- %s"
name
(Loc.to_file_colon_line loc1)
(Loc.to_file_colon_line loc2)
in
Lib.DB.create ()
~parent:installed_libs