fix PR#1744

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5669 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jacques Garrigue 2003-07-08 10:01:10 +00:00
parent 5536c2d5a6
commit af0591973a
5 changed files with 12 additions and 4 deletions

View File

@ -249,4 +249,6 @@ Type 'a u t should be an instance of g t
type 'a v = 'a u t constraint 'a = int
# Characters 38-58:
In the definition of v, type 'a list u should be 'a u
# type 'a t = 'a
type 'a u = A of 'a t
#

View File

@ -256,4 +256,6 @@ Type 'a u t should be an instance of g t
type 'a v = 'a u t constraint 'a = int
# Characters 38-58:
In the definition of v, type 'a list u should be 'a u
# type 'a t = 'a
type 'a u = A of 'a t
#

View File

@ -409,3 +409,7 @@ type 'a u = 'a and 'a v = 'a u t constraint 'a = int;;
(* Example of wrong expansion *)
type 'a u = < m : 'a v > and 'a v = 'a list u;;
(* PR#1744: Ctype.matches *)
type 'a t = 'a
type 'a u = A of 'a t;;

View File

@ -2092,11 +2092,11 @@ let rigidify ty =
unmark_type ty;
!vars
let all_distinct_vars vars =
let all_distinct_vars env vars =
let tyl = ref [] in
List.for_all
(fun ty ->
let ty = repr ty in
let ty = expand_head env ty in
if List.memq ty !tyl then false else
(tyl := ty :: !tyl; ty.desc = Tvar))
vars
@ -2105,7 +2105,7 @@ let matches env ty ty' =
let snap = snapshot () in
let vars = rigidify ty in
let ok =
try unify env ty ty'; all_distinct_vars vars
try unify env ty ty'; all_distinct_vars env vars
with Unify _ -> false
in
backtrack snap;

View File

@ -153,7 +153,7 @@ val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool
val rigidify: type_expr -> type_expr list
(* "Rigidify" a type and return its type variable *)
val all_distinct_vars: type_expr list -> bool
val all_distinct_vars: Env.t -> type_expr list -> bool
(* Check those types are all distinct type variables *)
val matches : Env.t -> type_expr -> type_expr -> bool
(* Same as [moregeneral false], implemented using the two above