Skip to content

Pack import fixes #1058

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 16 additions & 2 deletions middle_end/compilenv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ let get_unit_info comp_unit ~cmx_name =
let filename =
Load_path.find_uncap ((cmx_name |> CU.Name.to_string) ^ ".cmx") in
let (ui, crc) = read_unit_info filename in
if not (CU.equal ui.ui_unit comp_unit) then
if not (List.exists (CU.equal comp_unit) ui.ui_defines) then
(* CR vlaviron: the error message might be a bit odd, for instance
if the required unit was omitted from the pack by mistake.
But it's the correct message when no packs are involved, so
we're leaving it for now. *)
raise(Error(Illegal_renaming(comp_unit, ui.ui_unit, filename)));
cache_checks ui.ui_checks;
(Some ui, Some crc)
Expand All @@ -225,7 +229,17 @@ let get_unit_info comp_unit ~cmx_name =
(None, None)
end
in
let import = Import_info.create_normal comp_unit ~crc in
let import =
match infos with
| None ->
(* CR vlaviron: This is wrong, as we should register as import the
unit we tried to import (the one corresponding to [cmx_name]).
I don't know how to compute that unit though, and the following
code is correct when no packs are involved. *)
Import_info.create_normal comp_unit ~crc
| Some ui ->
Import_info.create_normal ui.ui_unit ~crc
in
current_unit.ui_imports_cmx <- import :: current_unit.ui_imports_cmx;
CU.Name.Tbl.add global_infos_table cmx_name infos;
infos
Expand Down