Commit 021847d7 authored by POTTIER Francois's avatar POTTIER Francois

Forbid [poly] variables under [@opaque].

parent a932893d
......@@ -2,8 +2,6 @@
TODO (REALLY)
Forbid a [poly] variable under @opaque.
Test polymorphic mode on CIL.
Check for TEMPORARYs.
......
......@@ -795,6 +795,15 @@ let constructor_declaration decl (cd : constructor_declaration) : case =
assert (length pss = arity);
let subjects = evarss xss in
(* Find out which type variables [alphas] are formal parameters of this
declaration and are marked [poly]. We have to universally quantify over
(variants of) these type variables in the type of the hook, below.
Furthermore, we forbid these type variables from appearing under [@opaque],
as that would cause us to generate code whose actual type is less general
than its expected type. *)
let alphas = poly_params decl in
check_poly_under_opaque alphas tys;
(* Get the name of this data constructor. *)
let datacon = cd.pcd_name.txt in
(* Create new names [rs] for the results of the recursive calls of visitor
......@@ -821,8 +830,6 @@ let constructor_declaration decl (cd : constructor_declaration) : case =
components of the existing block, then the address of the existing block is
returned; otherwise a new block is allocated, as in [map]. *)
let alphas = poly_params decl in
Exp.case
(ptuple (alias this (map (pconstr datacon) pss)))
(hook X.data
......@@ -880,6 +887,7 @@ let visit_decl (decl : type_declaration) : expression =
| Ptype_record (lds : label_declaration list), _ ->
let labels, tys = ld_labels lds, ld_tys (fix lds) in
(* See [constructor_declaration] for comments. *)
check_poly_under_opaque (poly_params decl) tys;
let subjects = accesses xs labels in
lambdas xs (
let rs = results labels
......
type 'a expr =
| EConst of ('a[@opaque])
| EAdd of 'a expr * 'a expr
[@@deriving
visitors { variety = "iter"; polymorphic = true },
visitors { variety = "map"; polymorphic = true },
visitors { variety = "endo"; polymorphic = true },
visitors { variety = "reduce"; polymorphic = true },
visitors { variety = "mapreduce"; polymorphic = true },
visitors { variety = "iter2"; polymorphic = true },
visitors { variety = "map2"; polymorphic = true },
visitors { variety = "reduce2"; polymorphic = true },
visitors { variety = "mapreduce2"; polymorphic = true }
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment