@@ -422,7 +422,7 @@ and resolve_result =
422422 | Hidden of Lib_info. external_ Hidden. t
423423 | Invalid of User_message. t
424424 | Ignore
425- | Redirect_in_the_same_db of (Loc. t * Lib_name. t)
425+ | Redirect_in_the_same_db of (Loc. t * Lib_name. t) list
426426 | Redirect of db * (Loc. t * Lib_name. t)
427427
428428let lib_config (t : lib ) = t.lib_config
@@ -1167,7 +1167,28 @@ end = struct
11671167 db.resolve name
11681168 >> = function
11691169 | Ignore -> Memo. return Status. Ignore
1170- | Redirect_in_the_same_db (_ , name' ) -> find_internal db name'
1170+ | Redirect_in_the_same_db redirects ->
1171+ let result = List. map ~f: (fun (_ , name' ) -> find_internal db name') redirects in
1172+ let * statuses =
1173+ Memo.List. map result ~f: (fun redirect ->
1174+ let * r = redirect in
1175+ Memo. return r)
1176+ in
1177+ Memo. return
1178+ (List. fold_left statuses ~init: Status. Not_found ~f: (fun acc status ->
1179+ match acc, status with
1180+ | Status. Found a , Status. Found b ->
1181+ let a = info a in
1182+ let b = info b in
1183+ let loc = Lib_info. loc b in
1184+ let dir_a = Lib_info. src_dir a in
1185+ let dir_b = Lib_info. src_dir b in
1186+ Status. Invalid (Error. duplicated ~loc ~name ~dir_a ~dir_b )
1187+ | Invalid _ , _ -> acc
1188+ | (Found _ as lib), (Hidden _ | Ignore | Not_found | Invalid _)
1189+ | (Hidden _ | Ignore | Not_found ), (Found _ as lib ) -> lib
1190+ | (Hidden _ | Ignore | Not_found ), (Hidden _ | Ignore | Not_found | Invalid _)
1191+ -> acc))
11711192 | Redirect (db' , (_ , name' )) -> find_internal db' name'
11721193 | Found libs ->
11731194 (match libs with
@@ -1860,7 +1881,7 @@ module DB = struct
18601881 | Hidden of Lib_info .external_ Hidden .t
18611882 | Invalid of User_message .t
18621883 | Ignore
1863- | Redirect_in_the_same_db of (Loc .t * Lib_name .t )
1884+ | Redirect_in_the_same_db of (Loc .t * Lib_name .t ) list
18641885 | Redirect of db * (Loc .t * Lib_name .t )
18651886
18661887 let found f = Found f
@@ -1877,8 +1898,10 @@ module DB = struct
18771898 | Hidden h -> variant " Hidden" [ Hidden. to_dyn (Lib_info. to_dyn Path. to_dyn) h ]
18781899 | Ignore -> variant " Ignore" []
18791900 | Redirect (_ , (_ , name )) -> variant " Redirect" [ Lib_name. to_dyn name ]
1880- | Redirect_in_the_same_db (_ , name ) ->
1881- variant " Redirect_in_the_same_db" [ Lib_name. to_dyn name ]
1901+ | Redirect_in_the_same_db redirects ->
1902+ variant
1903+ " Redirect_in_the_same_db"
1904+ [ (Dyn. list (fun (_ , name ) -> Lib_name. to_dyn name)) redirects ]
18821905 ;;
18831906 end
18841907
@@ -1911,7 +1934,7 @@ module DB = struct
19111934 >> | function
19121935 | Ok (Library pkg ) -> Found [ Dune_package.Lib. info pkg ]
19131936 | Ok (Deprecated_library_name d ) ->
1914- Redirect_in_the_same_db ( d.loc, d.new_public_name)
1937+ Redirect_in_the_same_db [ d.loc, d.new_public_name ]
19151938 | Ok (Hidden_library pkg ) -> Hidden (Hidden. unsatisfied_exist_if pkg)
19161939 | Error e ->
19171940 (match e with
0 commit comments