* Don't generate illegal Pfield's when compiling alias coercions

* Simplify lambda code when compiling packs

* Add regression test for pr8769

* Add Changes entry
master
Leo White 2019-06-28 14:31:42 +01:00
parent 30a210100c
commit 11edca8798
9 changed files with 47 additions and 1 deletions

View File

@ -344,6 +344,9 @@ OCaml 4.09.0
- #8701, #8725: Variance of constrained parameters causes principality issues
(Jacques Garrigue, report by Leo White, review by Gabriel Scherer)
- #8769, #8770: Fix assertion failure with -pack
(Leo White, review by Gabriel Scherer, report by Fabian @copy)
OCaml 4.08.0
------------

View File

@ -105,6 +105,7 @@ let make_package_object ~ppf_dump members targetobj targetname coercion
let main_module_block_size, code =
Translmod.transl_package_flambda components coercion
in
let code = Simplif.simplify_lambda code in
let program =
{ Lambda.
code;
@ -119,6 +120,7 @@ let make_package_object ~ppf_dump members targetobj targetname coercion
Translmod.transl_store_package components
(Ident.create_persistent targetname) coercion
in
let code = Simplif.simplify_lambda code in
let program =
{ Lambda.
code;

View File

@ -195,6 +195,7 @@ let build_global_target ~ppf_dump oc target_name members mapping pos coercion =
let lam =
Translmod.transl_package
components (Ident.create_persistent target_name) coercion in
let lam = Simplif.simplify_lambda lam in
if !Clflags.dump_lambda then
Format.fprintf ppf_dump "%a@." Printlambda.lambda lam;
let instrs =

View File

@ -72,7 +72,10 @@ let rec apply_coercion loc strict restr arg =
arg
| Tcoerce_structure(pos_cc_list, id_pos_list) ->
name_lambda strict arg (fun id ->
let get_field pos = Lprim(Pfield pos,[Lvar id], loc) in
let get_field pos =
if pos < 0 then lambda_unit
else Lprim(Pfield pos,[Lvar id], loc)
in
let lam =
Lprim(Pmakeblock(0, Immutable, None),
List.map (apply_coercion_field loc get_field) pos_cc_list,

View File

@ -0,0 +1,3 @@
module Rng : sig
module F : sig end
end

View File

@ -0,0 +1 @@
pr8769.ml

View File

@ -0,0 +1,32 @@
(* TEST
modules = "nocrypto.mli fortuna.ml rng.ml"
* setup-ocamlc.byte-build-env
** ocamlc.byte
module = "nocrypto.mli"
** ocamlc.byte
flags = "-for-pack Nocrypto"
module = "fortuna.ml"
** ocamlc.byte
flags = "-for-pack Nocrypto"
module = "rng.ml"
** ocamlc.byte
program = "nocrypto.cmo"
flags = "-pack"
all_modules = "fortuna.cmo rng.cmo"
* setup-ocamlopt.byte-build-env
** ocamlopt.byte
module = "nocrypto.mli"
** ocamlopt.byte
flags = "-for-pack Nocrypto"
module = "fortuna.ml"
** ocamlopt.byte
flags = "-for-pack Nocrypto"
module = "rng.ml"
** ocamlopt.byte
program = "nocrypto.cmx"
flags = "-pack"
all_modules = "fortuna.cmx rng.cmx"
*)

View File

@ -0,0 +1 @@
module F = Fortuna