Commit 7bf54c8b authored by Andrei Paskevich's avatar Andrei Paskevich

term hash-consing respects location

thanks to Johanness Kanig for the bug report and analysis
parent f1d95730
......@@ -397,7 +397,8 @@ module Hsterm = Hashcons.Make (struct
let equal t1 t2 =
oty_equal t1.t_ty t2.t_ty &&
t_equal_node t1.t_node t2.t_node &&
list_all2 (=) t1.t_label t2.t_label
list_all2 (=) t1.t_label t2.t_label &&
option_eq Loc.equal t1.t_loc t2.t_loc
let t_hash_bound (v,b,t) =
Hashcons.combine (vs_hash v) (bnd_hash b (t_hash t))
......@@ -426,7 +427,8 @@ module Hsterm = Hashcons.Make (struct
| Tfalse -> 1
let hash t =
Hashcons.combine (t_hash_node t.t_node)
Hashcons.combine2 (t_hash_node t.t_node)
(Hashcons.combine_option Loc.hash t.t_loc)
(Hashcons.combine_list Hashtbl.hash (oty_hash t.t_ty) t.t_label)
let t_vars_node = function
......
......@@ -68,12 +68,9 @@ let extract (b,e) =
let lc = e.pos_cnum - b.pos_bol in
(f,l,fc,lc)
let compare (_,l1,b1,e1) (_,l2,b2,e2) =
let c = Pervasives.compare l1 l2 in
if c <> 0 then c else
let c = Pervasives.compare b1 b2 in
if c <> 0 then c else
Pervasives.compare e1 e2
let compare = Pervasives.compare
let equal = Pervasives.(=)
let hash = Hashtbl.hash
let gen_report_position fmt (f,l,b,e) =
fprintf fmt "File \"%s\", line %d, characters %d-%d" f l b e
......
......@@ -43,6 +43,8 @@ val user_position : string -> int -> int -> int -> position
val get : position -> string * int * int * int
val compare : position -> position -> int
val equal : position -> position -> bool
val hash : position -> int
val gen_report_position : formatter -> position -> unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment