Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow contravariant arguments and covariant returns (fixed issue #783)

git-svn-id: http://haxe.googlecode.com/svn/trunk@4672 f16182fa-f095-11de-8f43-4547254af6c6
  • Loading branch information...
commit a8583fda0d45de266de3e013e799339b5d94caba 1 parent 84215b0
simon.krajewski@simn.de authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 typeload.ml
View
8 typeload.ml
@@ -330,7 +330,7 @@ let load_type_opt ?(opt=false) ctx p t =
let valid_redefinition ctx f1 t1 f2 t2 =
let valid t1 t2 =
- type_eq EqStrict t1 t2;
+ unify_raise ctx t1 t2 f2.cf_pos;
if is_null t1 <> is_null t2 then raise (Unify_error [Cannot_unify (t1,t2)]);
in
let t1, t2 = (match f1.cf_params, f2.cf_params with
@@ -344,12 +344,14 @@ let valid_redefinition ctx f1 t1 f2 t2 =
| TFun (args1,r1) , TFun (args2,r2) when List.length args1 = List.length args2 ->
List.iter2 (fun (n,o1,a1) (_,o2,a2) ->
if o1 <> o2 then raise (Unify_error [Not_matching_optional n]);
- valid a1 a2;
+ valid a2 a1;
) args1 args2;
+ unify_raise ctx r1 r2 f2.cf_pos;
valid r1 r2;
| _ , _ ->
(* in case args differs, or if an interface var *)
- valid t1 t2
+ type_eq EqStrict t1 t2;
+ if is_null t1 <> is_null t2 then raise (Unify_error [Cannot_unify (t1,t2)])
let copy_meta meta_src meta_target sl =
let meta = ref meta_target in

0 comments on commit a8583fd

Please sign in to comment.
Something went wrong with that request. Please try again.