Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locate doc improvements #1562

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
merlin 4.8
==========
undefined

+ merlin binary
- Prevent `Locate.get_doc` from crashing if `env_of_only_summary` fails.
(#1562, fixes #1561)

merlin 4.7
==========
Thu Nov 24 13:31:42 CEST 2022
Expand Down
11 changes: 9 additions & 2 deletions src/analysis/locate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,13 @@ let doc_from_uid ~config ~comp_unit uid =
Tast_iterator.default_iterator.value_binding sub vb)
}
in
let try_rebuild_env env =
try Envaux.env_of_only_summary env
with Envaux.Error err ->
log ~title:"doc_from_uid" "Error while rebuilding the environment: %a"
Logger.fmt (fun fmt -> Envaux.report_error fmt err);
env
in
let parse_attributes attrs =
let open Parsetree in
try Some (List.find_map attrs ~f:(fun attr ->
Expand All @@ -905,9 +912,9 @@ let doc_from_uid ~config ~comp_unit uid =
log ~title:"doc_from_uid" "Cmt loaded, itering on the typedtree";
begin match cmt_infos.cmt_annots with
| Interface s -> Some (`Interface { s with
sig_final_env = Envaux.env_of_only_summary s.sig_final_env})
sig_final_env = try_rebuild_env s.sig_final_env})
| Implementation str -> Some (`Implementation { str with
str_final_env = Envaux.env_of_only_summary str.str_final_env})
str_final_env = try_rebuild_env str.str_final_env})
| _ -> None
end
| Error _ -> None
Expand Down