Merge pull request #9991 from lpw25/reproducible-no-alias-deps

Fix reproducibility for `-no-alias-deps`
master
Leo White 2020-11-22 18:22:48 +00:00 committed by GitHub
commit d0ddf25f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 12 deletions

View File

@ -31,6 +31,9 @@ Working version
### Bug fixes:
- #9991: Fix reproducibility for `-no-alias-deps`
(Leo White, review by Gabriel Scherer and Florian Angeletti)
- #10005: Try expanding aliases in Ctype.nondep_type_rec
(Stephen Dolan, review by Gabriel Scherer, Leo White and Xavier Leroy)

View File

@ -4,7 +4,7 @@
** ocamlc.byte
compile_only = "true"
module = "cmis_on_file_system.ml"
flags="-bin-annot"
flags="-bin-annot -no-alias-deps -w '-49'"
*** script
script= "mv cmis_on_file_system.cmt lone.cmt"
**** ocamlc.byte
@ -12,7 +12,7 @@
compile_only="true"
***** ocamlc.byte
compile_only = "true"
flags="-bin-annot"
flags="-bin-annot -no-alias-deps -w '-49'"
module="cmis_on_file_system.ml"
****** compare-binary-files
program="cmis_on_file_system.cmt"
@ -24,3 +24,5 @@
at a given point in time *)
type t = int
let () = ()
module M = Cmis_on_file_system_companion

View File

@ -707,20 +707,34 @@ let find_name_module ~mark name tbl =
let add_persistent_structure id env =
if not (Ident.persistent id) then invalid_arg "Env.add_persistent_structure";
if not (Current_unit_name.is_ident id) then
let summary =
if Current_unit_name.is_ident id then env
else begin
let material =
(* This addition only observably changes the environment if it shadows a
non-persistent module already in the environment.
(See PR#9345) *)
match
IdTbl.find_name wrap_module ~mark:false (Ident.name id) env.modules
with
| exception Not_found | _, Mod_persistent -> env.summary
| _ -> Env_persistent (env.summary, id)
| exception Not_found | _, Mod_persistent -> false
| _ -> true
in
{ env with
modules = IdTbl.add id Mod_persistent env.modules;
summary
}
else
env
let summary =
if material then Env_persistent (env.summary, id)
else env.summary
in
let modules =
(* With [-no-alias-deps], non-material additions should not
affect the environment at all. We should only observe the
existence of a cmi when accessing components of the module.
(See #9991). *)
if material || not !Clflags.transparent_modules then
IdTbl.add id Mod_persistent env.modules
else
env.modules
in
{ env with modules; summary }
end
let components_of_module ~alerts ~uid env fs ps path addr mty =
{