Skip to content

Commit 5a3d791

Browse files
committed
Use the latest Uid if declaration is not found
1 parent 1c958b3 commit 5a3d791

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/analysis/locate.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,16 @@ let load_cmt ~config comp_unit ml_or_mli =
310310
Ok (source_file, cmt_infos)
311311
| None -> Error ()
312312

313-
let find_declaration_uid ~env ~decl_uid path =
314-
let rec non_alias_declaration_uid path =
315-
let md = Env.find_module path env in
316-
match md.md_type with
317-
| Mty_ident _ | Mty_signature _ | Mty_functor _ | Mty_for_hole -> md.md_uid
318-
| Mty_alias path -> non_alias_declaration_uid path
313+
let find_declaration_uid ~env ~fallback_uid path =
314+
let rec non_alias_declaration_uid ~fallback_uid path =
315+
match Env.find_module path env with
316+
| { md_type = Mty_alias path; md_uid = fallback_uid; _ } ->
317+
non_alias_declaration_uid ~fallback_uid path
318+
| { md_type = Mty_ident _ | Mty_signature _ | Mty_functor _ | Mty_for_hole;
319+
md_uid; _ }-> md_uid
320+
| exception Not_found -> fallback_uid
319321
in
320-
try non_alias_declaration_uid path
321-
with Not_found -> decl_uid
322+
non_alias_declaration_uid ~fallback_uid path
322323

323324
let uid_of_path ~config ~env ~ml_or_mli ~decl_uid path ns =
324325
let module Shape_reduce =
@@ -343,7 +344,7 @@ let uid_of_path ~config ~env ~ml_or_mli ~decl_uid path ns =
343344
end)
344345
in
345346
match ml_or_mli with
346-
| `MLI -> Some (find_declaration_uid ~decl_uid ~env path)
347+
| `MLI -> Some (find_declaration_uid ~fallback_uid:decl_uid ~env path)
347348
| `ML ->
348349
let shape = Env.shape_of_path ~namespace:ns env path in
349350
log ~title:"shape_of_path" "initial: %a"

0 commit comments

Comments
 (0)