Browse Source

fixed typing of arrow funcs with empty bodies (closes #9843)

Aleksandr Kuzmenko 5 years ago
parent
commit
ee69e5346a
2 changed files with 18 additions and 1 deletions
  1. 2 1
      src/typing/typer.ml
  2. 16 0
      tests/display/src/cases/Issue9843.hx

+ 2 - 1
src/typing/typer.ml

@@ -1389,7 +1389,8 @@ and type_return ?(implicit=false) ctx e with_type p =
 		end;
 		try
 			let with_expected_type =
-				if implicit then WithType.of_implicit_return ctx.ret
+				if ExtType.is_void (follow ctx.ret) then WithType.no_value
+				else if implicit then WithType.of_implicit_return ctx.ret
 				else WithType.with_type ctx.ret
 			in
 			let e = type_expr ctx e with_expected_type in

+ 16 - 0
tests/display/src/cases/Issue9843.hx

@@ -0,0 +1,16 @@
+package cases;
+
+class Issue9843 extends DisplayTestCase {
+	/**
+		class Main {
+			static function main() {
+				test(() -> {});
+			}
+
+			static function test(fn:()->Void) {}
+		}
+	**/
+	function test() {
+		arrayEq([], diagnostics());
+	}
+}