From c9debef593367a5f39f32d0ad76fad4c21cd56f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Nguy=E1=BB=85n?= Date: Thu, 7 May 2015 11:07:07 +0200 Subject: [PATCH] Fix a regression where polymorphic variables would not be chosen in favor of monomorphic ones during the 'single' phase of constraint generation. --- types/type_tallying.ml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/types/type_tallying.ml b/types/type_tallying.ml index 06fc6e67..a22a3213 100644 --- a/types/type_tallying.ml +++ b/types/type_tallying.ml @@ -223,6 +223,14 @@ let toplevel then ConstrSet.unsat else ConstrSet.singleton x cst in + let var_compare v1 v2 = + let mono1 = Var.Set.mem delta v1 in + let mono2 = Var.Set.mem delta v2 in + match mono1, mono2 with + | false, true -> -1 + | true, false -> 1 + | _ -> Var.compare v1 v2 + in match lpos, lneg with [], (`Var x)::neg -> let t = single (module V) false x [] neg in @@ -233,7 +241,9 @@ let toplevel singleton x (empty, t) | (`Var x)::pos, (`Var y)::neg -> - if Var.compare x y < 0 then + DEBUG toplevel (Format.eprintf + "@[ - pos/neg case = %a, %a @]@\n" Var.print x Var.print y); + if var_compare x y < 0 then let t = single (module V) true x pos lneg in singleton x (empty, t) else -- 2.22.0