Bläddra i källkod

[server] bind any signature monomorph to Dynamic after typing

closes #10653
This is fine
Simon Krajewski 3 år sedan
förälder
incheckning
8bc4356e7d

+ 2 - 1
src/filters/filters.ml

@@ -797,7 +797,8 @@ let update_cache_dependencies com t =
 				| Some t ->
 					check_t m t
 				| _ ->
-					()
+					(* Bind any still open monomorph that's part of a signature to Dynamic now (issue #10653) *)
+					Monomorph.do_bind r t_dynamic;
 		end
 		| TLazy f ->
 			check_t m (lazy_type f)

+ 16 - 0
tests/server/src/cases/issues/Issue10653.hx

@@ -0,0 +1,16 @@
+package cases.issues;
+
+class Issue10653 extends TestCase {
+	function test(_) {
+		vfs.putContent("Test.hx", getTemplate("issues/Issue10653/Test.hx"));
+		vfs.putContent("Main.hx", getTemplate("issues/Issue10653/MainBefore.hx"));
+		var args = ["-main", "Main", "--js", "no.js", "--no-output"];
+		runHaxe(args);
+		vfs.putContent("Main.hx", getTemplate("issues/Issue10653/MainAfter.hx"));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
+		Assert.isTrue(lastResult.stderr.length == 2);
+	}
+}

+ 8 - 0
tests/server/test/templates/issues/Issue10653/MainAfter.hx

@@ -0,0 +1,8 @@
+class Main {
+	static function main() {
+		var x = Test.test();
+		x = new Main();
+	}
+
+	function new() {}
+}

+ 7 - 0
tests/server/test/templates/issues/Issue10653/MainBefore.hx

@@ -0,0 +1,7 @@
+class Main {
+	static function main() {
+		var x = Test.test();
+	}
+
+	function new() {}
+}

+ 5 - 0
tests/server/test/templates/issues/Issue10653/Test.hx

@@ -0,0 +1,5 @@
+class Test {
+	static public function test() {
+		return null;
+	}
+}