aboutsummaryrefslogtreecommitdiff
path: root/kernel/environ.mli
diff options
context:
space:
mode:
authorGaëtan Gilbert2019-06-04 14:39:29 +0200
committerGaëtan Gilbert2019-10-24 16:33:26 +0200
commitd13e7e924437b043f83b6a47bfefda69379264b7 (patch)
tree06cbf24074c8c8e1803bcaad8c4e297d15149ca9 /kernel/environ.mli
parent4c779c4fee1134c5d632885de60db73d56021df4 (diff)
Raise an anomaly when looking up unknown constant/inductive
If you have access to a kernel name you also should have the environment in which it is defined, barring hacks. In order to disfavor hacks we make the standard lookups raise anomalies so that people are forced to admit they rely on the internals of the environment. We find that hackers operated on the code for side effects, for finding inductive schemes, for simpl and for Print Assumptions. They attempted to operate on funind but the error handling code they wrote would have raised another Not_found instead of being useful. All these uses are indeed hacky so I am satisfied that we are not forcing new hacks on callers.
Diffstat (limited to 'kernel/environ.mli')
-rw-r--r--kernel/environ.mli10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/environ.mli b/kernel/environ.mli
index 5af2a7288b..782ea1c666 100644
--- a/kernel/environ.mli
+++ b/kernel/environ.mli
@@ -201,10 +201,12 @@ val add_constant_key : Constant.t -> Opaqueproof.opaque constant_body -> link_in
val lookup_constant_key : Constant.t -> env -> constant_key
(** Looks up in the context of global constant names
- raises [Not_found] if the required path is not found *)
+ raises an anomaly if the required path is not found *)
val lookup_constant : Constant.t -> env -> Opaqueproof.opaque constant_body
val evaluable_constant : Constant.t -> env -> bool
+val mem_constant : Constant.t -> env -> bool
+
(** New-style polymorphism *)
val polymorphic_constant : Constant.t -> env -> bool
val polymorphic_pconstant : pconstant -> env -> bool
@@ -215,7 +217,7 @@ val type_in_type_constant : Constant.t -> env -> bool
[c] is opaque, [NotEvaluableConst NoBody] if it has no
body, [NotEvaluableConst IsProj] if [c] is a projection,
[NotEvaluableConst (IsPrimitive p)] if [c] is primitive [p]
- and [Not_found] if it does not exist in [env] *)
+ and an anomaly if it does not exist in [env] *)
type const_evaluation_result =
| NoBody
@@ -254,9 +256,11 @@ val add_mind_key : MutInd.t -> mind_key -> env -> env
val add_mind : MutInd.t -> mutual_inductive_body -> env -> env
(** Looks up in the context of global inductive names
- raises [Not_found] if the required path is not found *)
+ raises an anomaly if the required path is not found *)
val lookup_mind : MutInd.t -> env -> mutual_inductive_body
+val mem_mind : MutInd.t -> env -> bool
+
(** The universe context associated to the inductive, empty if not
polymorphic *)
val mind_context : env -> MutInd.t -> Univ.AUContext.t