Browse Source

[typer] fix Void detection for function return variance

closes #8101
Simon Krajewski 6 năm trước cách đây
mục cha
commit
c4d523088e
2 tập tin đã thay đổi với 16 bổ sung1 xóa
  1. 1 1
      src/core/type.ml
  2. 15 0
      tests/unit/src/unit/issues/Issue8101.hx

+ 1 - 1
src/core/type.ml

@@ -2045,7 +2045,7 @@ let rec unify a b =
 	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
 		let i = ref 0 in
 		(try
-			(match r2 with
+			(match follow r2 with
 			| TAbstract ({a_path=[],"Void"},_) -> incr i
 			| _ -> unify r1 r2; incr i);
 			List.iter2 (fun (_,o1,t1) (_,o2,t2) ->

+ 15 - 0
tests/unit/src/unit/issues/Issue8101.hx

@@ -0,0 +1,15 @@
+package unit.issues;
+
+import utest.Assert;
+
+class Issue8101 extends unit.Test {
+	function test() {
+		var a;
+		f1 = () -> a = "";
+		f2 = () -> a = "";
+		Assert.pass();
+	}
+
+	static dynamic function f1():Void {}
+	static dynamic function f2() {}
+}