summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2014-04-04 04:17:20 +0000
committerJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2014-04-04 04:17:20 +0000
commitfc61342e09ca30c806af2c7941c40ae458c5b6c1 (patch)
treeeebe9e048089872e30afbcbdd76f90993664251d
parentcfb1250590ddd4f8dd384bcab63b584ed5452cfe (diff)
Fix PR#6348
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14528 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes1
-rw-r--r--typing/ctype.ml15
2 files changed, 15 insertions, 1 deletions
diff --git a/Changes b/Changes
index 185a61b7a..a3cdb827c 100644
--- a/Changes
+++ b/Changes
@@ -85,6 +85,7 @@ Bug fixes:
- PR#6293: Assert_failure with invalid package type
- PR#6307: Behavior of 'module type of' w.r.t. module aliases
- PR#6346: Build failure with latest version of xcode on OSX
+- PR#6348: Unification failure for GADT when original definition is hidden
- PR#6352: Automatic removal of optional arguments and sequencing
- fix -dsource printing of "external _pipe = ..."
(Gabriel Scherer)
diff --git a/typing/ctype.ml b/typing/ctype.ml
index d75dea43e..6cee02077 100644
--- a/typing/ctype.ml
+++ b/typing/ctype.ml
@@ -1964,6 +1964,18 @@ let non_aliasable p decl =
(* in_pervasives p || (subsumed by in_current_module) *)
in_current_module p && decl.type_newtype_level = None
+(* Check for datatypes carefully; see PR#6348 *)
+let rec expands_to_datatype env ty =
+ let ty = repr ty in
+ match ty.desc with
+ Tconstr (p, _, _) ->
+ begin try
+ is_datatype (Env.find_type p env) ||
+ expands_to_datatype env (try_expand_once env ty)
+ with Not_found | Cannot_expand -> false
+ end
+ | _ -> false
+
(* mcomp type_pairs subst env t1 t2 does not raise an
exception if it is possible that t1 and t2 are actually
equal, assuming the types in type_pairs are equal and
@@ -2396,7 +2408,8 @@ and unify3 env t1 t1' t2 t2' =
| (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) when Path.same p1 p2 ->
if !umode = Expression || not !generate_equations
|| in_current_module p1 (* || in_pervasives p1 *)
- || try is_datatype (Env.find_type p1 !env) with Not_found -> false
+ || List.exists (expands_to_datatype !env) [t1'; t1; t2]
+ (*try is_datatype (Env.find_type p1 !env) with Not_found -> false*)
then
unify_list env tl1 tl2
else