diff options
| author | Pierre-Marie Pédrot | 2019-10-30 14:18:37 +0100 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2019-10-30 14:18:37 +0100 |
| commit | 964e3f409b4db3c682913a4d90394e96453a1274 (patch) | |
| tree | 072e0b588ad881816dde47d9cd8796bbcc0d081b /clib/cMap.ml | |
| parent | 7634426a7a6de08ff0ea172a0770b9a159b25934 (diff) | |
| parent | d13e7e924437b043f83b6a47bfefda69379264b7 (diff) | |
Merge PR #10303: Raise an anomaly when looking up unknown constant/inductive
Reviewed-by: ppedrot
Diffstat (limited to 'clib/cMap.ml')
| -rw-r--r-- | clib/cMap.ml | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clib/cMap.ml b/clib/cMap.ml index baac892b9e..8d822667c3 100644 --- a/clib/cMap.ml +++ b/clib/cMap.ml @@ -58,6 +58,7 @@ module MapExt (M : Map.OrderedType) : sig type 'a map = 'a Map.Make(M).t val set : M.t -> 'a -> 'a map -> 'a map + val get : M.t -> 'a map -> 'a val modify : M.t -> (M.t -> 'a -> 'a) -> 'a map -> 'a map val domain : 'a map -> Set.Make(M).t val bind : (M.t -> 'a) -> Set.Make(M).t -> 'a map @@ -124,6 +125,14 @@ struct if r == r' then s else map_inj (MNode {l; v=k'; d=v'; r=r'; h}) + let rec get k (s:'a map) : 'a = match map_prj s with + | MEmpty -> assert false + | MNode {l; v=k'; d=v; r; h} -> + let c = M.compare k k' in + if c < 0 then get k l + else if c = 0 then v + else get k r + let rec modify k f (s : 'a map) : 'a map = match map_prj s with | MEmpty -> raise Not_found | MNode {l; v; d; r; h} -> @@ -324,5 +333,4 @@ module Make(M : Map.OrderedType) = struct include Map.Make(M) include MapExt(M) - let get k m = try find k m with Not_found -> assert false end |
