aboutsummaryrefslogtreecommitdiffhomepage
path: root/library/lib.ml
diff options
context:
space:
mode:
Diffstat (limited to 'library/lib.ml')
-rw-r--r--library/lib.ml11
1 files changed, 10 insertions, 1 deletions
diff --git a/library/lib.ml b/library/lib.ml
index bb0ad74ca..4743290ae 100644
--- a/library/lib.ml
+++ b/library/lib.ml
@@ -484,13 +484,22 @@ let section_segment_of_constant con =
let section_segment_of_mutual_inductive kn =
Names.KNmap.find kn (snd (pi3 (List.hd !sectab)))
+let rec list_mem_assoc_in_triple x = function
+ | [] -> raise Not_found
+ | (a,_,_)::l -> compare a x = 0 or list_mem_assoc_in_triple x l
+
let section_instance = function
- | VarRef id -> [||]
+ | VarRef id ->
+ if list_mem_assoc_in_triple id (pi1 (List.hd !sectab)) then [||]
+ else raise Not_found
| ConstRef con ->
Names.Cmap.find con (fst (pi2 (List.hd !sectab)))
| IndRef (kn,_) | ConstructRef ((kn,_),_) ->
Names.KNmap.find kn (snd (pi2 (List.hd !sectab)))
+let is_in_section ref =
+ try ignore (section_instance ref); true with Not_found -> false
+
let init_sectab () = sectab := []
let freeze_sectab () = !sectab
let unfreeze_sectab s = sectab := s