Nicolas Cannasse vor 8 Jahren
Ursprung
Commit
c4eb88fc07

+ 4 - 0
.gitignore

@@ -97,3 +97,7 @@ tests/misc/projects/Issue4070/cpp/
 _build/
 _build/
 Makefile.dependencies
 Makefile.dependencies
 Makefile.modules
 Makefile.modules
+
+/tests/unit/compiler_loops/All.n
+
+/tests/unit/compiler_loops/log.txt

+ 12 - 1
src/typing/type.ml

@@ -1779,6 +1779,17 @@ let rec unify a b =
 		(match !t with
 		(match !t with
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| Some t -> unify a t)
 		| Some t -> unify a t)
+	| TType (t1,tl1), TType (t2,tl2) when t1 == t2 ->
+		if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!unify_stack)) then begin
+			try
+				unify_stack := (a,b) :: !unify_stack;
+				List.iter2 unify tl1 tl2;
+				unify_stack := List.tl !unify_stack;
+			with
+				Unify_error l ->
+					unify_stack := List.tl !unify_stack;
+					error (cannot_unify a b :: l)
+		end
 	| TType (t,tl) , _ ->
 	| TType (t,tl) , _ ->
 		if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!unify_stack)) then begin
 		if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!unify_stack)) then begin
 			try
 			try
@@ -2050,7 +2061,7 @@ and unify_anons a b a1 a2 =
 				| _ -> error [invalid_kind n f1.cf_kind f2.cf_kind]);
 				| _ -> error [invalid_kind n f1.cf_kind f2.cf_kind]);
 			if f2.cf_public && not f1.cf_public then error [invalid_visibility n];
 			if f2.cf_public && not f1.cf_public then error [invalid_visibility n];
 			try
 			try
-				unify_with_access f1.cf_type f2;
+				unify_with_access (field_type f1) f2;
 				(match !(a1.a_status) with
 				(match !(a1.a_status) with
 				| Statics c when not (Meta.has Meta.MaybeUsed f1.cf_meta) -> f1.cf_meta <- (Meta.MaybeUsed,[],f1.cf_pos) :: f1.cf_meta
 				| Statics c when not (Meta.has Meta.MaybeUsed f1.cf_meta) -> f1.cf_meta <- (Meta.MaybeUsed,[],f1.cf_pos) :: f1.cf_meta
 				| _ -> ());
 				| _ -> ());

+ 11 - 0
tests/unit/compiler_loops/All.hx

@@ -0,0 +1,11 @@
+class All {
+
+	static function main() {
+		for( f in sys.FileSystem.readDirectory(".") ) {
+			if( !StringTools.endsWith(f,".hx") || f == "All.hx" ) continue;
+			Sys.println(f);
+			Sys.command("haxe",[f.substr(0,-3)]);
+		}
+	}
+
+}

+ 16 - 0
tests/unit/compiler_loops/Issue5785.hx

@@ -0,0 +1,16 @@
+typedef Observable<T> = {
+	function flatten<U>():Stream<U>;
+};
+typedef Stream<T> = {
+	function flatten<V>():Stream<V>;
+	function takeUntilBy<U>(otherObs:Observable<U>):Stream<U>;
+	function bufferWhileBy():Stream<Array<T>>;
+};
+
+class Main {
+
+  public static function main() {
+    var mouseMoves : Stream<Int> = null;
+    mouseMoves.takeUntilBy(mouseMoves);
+  } 
+}

+ 1 - 1
tests/unit/compiler_loops/Issue6038.hx

@@ -1,5 +1,5 @@
 class Promise<T> {
 class Promise<T> {
-    function then<TOut>():Promise<TOut> { return null; }
+    public function then<TOut>():Promise<TOut> { return null; }
 }
 }
 
 
 typedef Thenable<T> = {
 typedef Thenable<T> = {