aboutsummaryrefslogtreecommitdiffhomepage
path: root/checker/subtyping.ml
diff options
context:
space:
mode:
authorGravatar Maxime Dénès <mail@maximedenes.fr>2018-02-21 18:53:56 +0100
committerGravatar Maxime Dénès <mail@maximedenes.fr>2018-02-21 18:53:56 +0100
commit6ee9f47718fa9929de4d8e724d9df6d389ea9dc8 (patch)
tree99651982cd8f5c20ebc86a2124297af72884e97d /checker/subtyping.ml
parentaec63ba9c8f6840d98ba731640a786138d836343 (diff)
parentd50cee3fa401246061c106248b749be03e108298 (diff)
Merge PR #6740: Adding a sanity check on inductive variance subtyping.
Diffstat (limited to 'checker/subtyping.ml')
-rw-r--r--checker/subtyping.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/checker/subtyping.ml b/checker/subtyping.ml
index 98a9c8250..77201c25b 100644
--- a/checker/subtyping.ml
+++ b/checker/subtyping.ml
@@ -108,6 +108,14 @@ let check_inductive env mp1 l info1 mib2 spec2 subst1 subst2=
let env = check_polymorphic_instance error env auctx auctx' in
env, Univ.make_abstract_instance auctx'
| Cumulative_ind cumi, Cumulative_ind cumi' ->
+ (** Currently there is no way to control variance of inductive types, but
+ just in case we require that they are in a subtyping relation. *)
+ let () =
+ let v = Univ.ACumulativityInfo.variance cumi in
+ let v' = Univ.ACumulativityInfo.variance cumi' in
+ if not (Array.for_all2 Univ.Variance.check_subtype v' v) then
+ CErrors.anomaly Pp.(str "Variance mismatch for " ++ MutInd.print kn)
+ in
let auctx = Univ.ACumulativityInfo.univ_context cumi in
let auctx' = Univ.ACumulativityInfo.univ_context cumi' in
let env = check_polymorphic_instance error env auctx auctx' in