2
0
Эх сурвалжийг харах

use unification instead of equality for array access resolution (closes #2004)

Simon Krajewski 12 жил өмнө
parent
commit
4c6a2ad151
1 өөрчлөгдсөн 17 нэмэгдсэн , 4 устгасан
  1. 17 4
      typer.ml

+ 17 - 4
typer.ml

@@ -279,10 +279,23 @@ let find_array_access a pl c t1 t2 is_set =
 			loop cfl
 			loop cfl
 		| cf :: cfl ->
 		| cf :: cfl ->
 			match follow (apply_params a.a_types pl (monomorphs cf.cf_params cf.cf_type)) with
 			match follow (apply_params a.a_types pl (monomorphs cf.cf_params cf.cf_type)) with
-			| TFun([(_,_,tab);(_,_,ta1);(_,_,ta2)],r) as tf when is_set && type_iseq tab ta && type_iseq ta1 t1 && type_iseq ta2 t2 ->
-				cf,tf,r
-			| TFun([(_,_,tab);(_,_,ta1)],r) as tf when not is_set && type_iseq tab ta && type_iseq ta1 t1 ->
-				cf,tf,r
+			| TFun([(_,_,tab);(_,_,ta1);(_,_,ta2)],r) as tf when is_set ->
+				begin try
+					Type.unify tab ta;
+					Type.unify t1 ta1;
+					Type.unify t2 ta2;
+					cf,tf,r
+				with Unify_error _ ->
+					loop cfl
+				end
+			| TFun([(_,_,tab);(_,_,ta1)],r) as tf when not is_set ->
+				begin try
+					Type.unify tab ta;
+					Type.unify t1 ta1;
+					cf,tf,r
+				with Unify_error _ ->
+					loop cfl
+				end
 			| _ -> loop cfl
 			| _ -> loop cfl
 	in
 	in
 	loop a.a_array
 	loop a.a_array