Skip to content

Commit

Permalink
Add real disambiguator instead of modifying string to resolve name cl…
Browse files Browse the repository at this point in the history
…ashes in bundles.
  • Loading branch information
maximebuyse committed Dec 19, 2024
1 parent ef31110 commit b7a9e34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions engine/lib/concrete_ident/concrete_ident.ml
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ module Create = struct
let constructor name =
let path = name.def_id.path @ [ { data = Ctor; disambiguator = 0 } ] in
{ name with def_id = { name.def_id with path } }

let add_disambiguator name disambiguator =
let path = name.def_id.path in
let last = List.last_exn path in
let path =
List.drop_last_exn path @ [ { data = last.data; disambiguator } ]
in
{ name with def_id = { name.def_id with path } }
end

let lookup_raw_impl_info (impl : t) : Types.impl_infos option =
Expand Down
4 changes: 4 additions & 0 deletions engine/lib/concrete_ident/concrete_ident.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module Create : sig
val map_last : f:(string -> string) -> t -> t
(** [map_last f ident] applies [f] on the last chunk of [ident]'s
path if it holds a string *)

val add_disambiguator : t -> int -> t
(** [add_disambiguator ident d] changes the disambiguator on
the last chunk of [ident]'s path to [d] *)
end

type view = { crate : string; path : string list; definition : string }
Expand Down
5 changes: 1 addition & 4 deletions engine/lib/dependencies.ml
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,7 @@ module Make (F : Features.T) = struct
(List.mem duplicates (new_name_under_ns id)
~equal:Concrete_ident.equal)
then id
else
Concrete_ident.Create.map_last
~f:(fun name -> name ^ (Concrete_ident.hash id |> Int.to_string))
id
else Concrete_ident.Create.add_disambiguator id (Concrete_ident.hash id)
in
let renamings =
List.map
Expand Down

0 comments on commit b7a9e34

Please sign in to comment.