File tree 2 files changed +19
-13
lines changed
2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -817,14 +817,13 @@ let rebuild_ty_under_params
817
817
end
818
818
params
819
819
in
820
- let substituted = ref false in
821
820
let rec rebuild_ty t =
822
821
let base = ty_fold_rebuild (fun t -> t) in
823
822
let ty_fold_param (i , mut ) =
824
823
let param = Ast. TY_param (i, mut) in
825
824
match htab_search pmap param with
826
825
None -> param
827
- | Some arg -> (substituted := true ; arg)
826
+ | Some arg -> arg
828
827
in
829
828
let ty_fold_named n =
830
829
let rec rebuild_name n =
@@ -863,7 +862,7 @@ let rebuild_ty_under_params
863
862
begin
864
863
match htab_search nmap id with
865
864
None -> Ast. TY_named n
866
- | Some arg -> (substituted := true ; arg)
865
+ | Some arg -> arg
867
866
end
868
867
| _ -> Ast. TY_named n
869
868
in
@@ -873,14 +872,7 @@ let rebuild_ty_under_params
873
872
ty_fold_named = ty_fold_named;
874
873
}
875
874
in
876
- let t' = fold_ty fold t in
877
- (* FIXME (issue #77): "substituted" and "ty'" here are only required
878
- * because the current type-equality-comparison code in Type uses <>
879
- * and will judge some cases, such as rebuilt tags, as unequal simply
880
- * due to the different hashtable order in the fold. *)
881
- if ! substituted
882
- then t'
883
- else t
875
+ fold_ty fold t
884
876
in
885
877
rebuild_ty ty
886
878
;;
Original file line number Diff line number Diff line change @@ -220,6 +220,21 @@ let htab_put (htab:('a,'b) Hashtbl.t) (a:'a) (b:'b) : unit =
220
220
Hashtbl. add htab a b
221
221
;;
222
222
223
+ (* This is completely ridiculous, but it turns out that ocaml hashtables are
224
+ * order-of-element-addition sensitive when it comes to the built-in
225
+ * polymorphic comparison operator. So you have to canonicalize them after
226
+ * you've stopped adding things to them if you ever want to use them in a
227
+ * term that requires structural comparison to work. Sigh.
228
+ *)
229
+
230
+ let htab_canonicalize (htab :('a,'b) Hashtbl.t ) : ('a,'b) Hashtbl.t =
231
+ let n = Hashtbl. create (Hashtbl. length htab) in
232
+ Array. iter
233
+ (fun k -> Hashtbl. add n k (Hashtbl. find htab k))
234
+ (sorted_htab_keys htab);
235
+ n
236
+ ;;
237
+
223
238
let htab_map
224
239
(htab :('a,'b) Hashtbl.t )
225
240
(f :'a -> 'b -> ('c * 'd) )
@@ -230,10 +245,9 @@ let htab_map
230
245
htab_put ntab c d
231
246
in
232
247
Hashtbl. iter g htab;
233
- ntab
248
+ htab_canonicalize ( ntab)
234
249
;;
235
250
236
-
237
251
let htab_fold
238
252
(fn :'a -> 'b -> 'c -> 'c )
239
253
(init :'c )
You can’t perform that action at this time.
0 commit comments