@@ -473,7 +473,7 @@ let context uctx =
473473type named_universes_entry = universes_entry * UnivNames .universe_binders
474474
475475let check_mono_sort_constraints uctx =
476- let (uvar, (qcst, ucst)) = uctx in
476+ let (uvar, (qcst, ucst)) = uctx.local in
477477 (* This looks very stringent but it passes nonetheless all the tests? *)
478478 let () = assert (Sorts.ElimConstraints. is_empty qcst) in
479479 (uvar, ucst)
@@ -483,7 +483,7 @@ let univ_entry ~poly uctx =
483483 let entry =
484484 if poly then Polymorphic_entry (context uctx)
485485 else
486- let uctx = check_mono_sort_constraints (context_set uctx) in
486+ let uctx = check_mono_sort_constraints uctx in
487487 Monomorphic_entry uctx
488488 in
489489 entry, binders
@@ -1091,18 +1091,20 @@ let check_template_univ_decl uctx ~template_qvars decl =
10911091 if not (QVar.Set. equal template_qvars (QState. undefined uctx.sort_variables))
10921092 then CErrors. anomaly Pp. (str " Bugged template univ declaration." )
10931093 in
1094+ (* XXX: when the kernel takes template entries closer to the polymorphic ones,
1095+ we should perform some additional checks here. *)
1096+ let () = assert (Sorts.ElimConstraints. is_empty decl.univdecl_elim_constraints) in
10941097 let levels, csts = uctx.local in
10951098 let () =
10961099 let prefix = decl.univdecl_instance in
10971100 if not decl.univdecl_extensible_instance
10981101 then check_universe_context_set ~prefix levels uctx.names
10991102 in
1100- if decl.univdecl_extensible_constraints then uctx.local
1101- else begin
1102- check_implication uctx
1103- (univ_decl_csts decl) csts;
1104- levels, (decl.univdecl_elim_constraints,decl.univdecl_univ_constraints)
1105- end
1103+ if decl.univdecl_extensible_constraints then
1104+ PConstraints.ContextSet. univ_context_set uctx.local
1105+ else
1106+ let () = check_implication uctx (univ_decl_csts decl) csts in
1107+ (levels, decl.univdecl_univ_constraints)
11061108
11071109let check_mono_univ_decl uctx decl =
11081110 (* Note: if [decl] is [default_univ_decl], behave like [uctx.local] *)
@@ -1117,7 +1119,7 @@ let check_mono_univ_decl uctx decl =
11171119 if not decl.univdecl_extensible_instance
11181120 then check_universe_context_set ~prefix levels uctx.names
11191121 in
1120- if decl.univdecl_extensible_constraints then check_mono_sort_constraints uctx.local
1122+ if decl.univdecl_extensible_constraints then check_mono_sort_constraints uctx
11211123 else
11221124 let () = assert (Sorts.ElimConstraints. is_empty (fst csts)) in
11231125 let () = check_implication uctx (univ_decl_csts decl) csts in
@@ -1156,12 +1158,10 @@ let check_univ_decl ~poly uctx decl =
11561158 in
11571159 entry, binders
11581160
1159- let restrict_universe_context (univs , csts ) keep =
1161+ let restrict_universe_context (univs , univ_csts ) keep =
11601162 let removed = Level.Set. diff univs keep in
1161- if Level.Set. is_empty removed then univs, csts
1163+ if Level.Set. is_empty removed then univs, univ_csts
11621164 else
1163- let elim_csts = PConstraints. qualities csts in
1164- let univ_csts = PConstraints. univs csts in
11651165 let allunivs = UnivConstraints. fold (fun (u ,_ ,v ) all -> Level.Set. add u (Level.Set. add v all)) univ_csts univs in
11661166 let g = UGraph. initial_universes in
11671167 let g = Level.Set. fold (fun v g ->
@@ -1171,17 +1171,21 @@ let restrict_universe_context (univs, csts) keep =
11711171 let allkept = Level.Set. union (UGraph. domain UGraph. initial_universes) (Level.Set. diff allunivs removed) in
11721172 let univ_csts = UGraph. constraints_for ~kept: allkept g in
11731173 let univ_csts = UnivConstraints. filter (fun (l ,d ,r ) -> not (Level. is_set l && d == Le )) univ_csts in
1174- (Level.Set. inter univs keep, PConstraints. make elim_csts univ_csts)
1174+ (Level.Set. inter univs keep, univ_csts)
1175+
1176+ let restrict_universe_pcontext (us , (qcst , ucst )) keep =
1177+ let (us, ucst) = restrict_universe_context (us, ucst) keep in
1178+ (us, (qcst, ucst))
11751179
11761180let restrict uctx vars =
11771181 let vars = Id.Map. fold (fun na l vars -> Level.Set. add l vars)
11781182 (snd (fst uctx.names)) vars
11791183 in
1180- let uctx' = restrict_universe_context uctx.local vars in
1184+ let uctx' = restrict_universe_pcontext uctx.local vars in
11811185 { uctx with local = uctx' }
11821186
11831187let restrict_even_binders uctx vars =
1184- let uctx' = restrict_universe_context uctx.local vars in
1188+ let uctx' = restrict_universe_pcontext uctx.local vars in
11851189 { uctx with local = uctx' }
11861190
11871191let restrict_univ_constraints uctx csts =
0 commit comments