Browse Source

transform `return Void` to `Void; return;` in the analyzer (closes #5027)

This addresses the cases that are missed during initial typing, probably due to monomorphs not being bound to Void yet.
Simon Krajewski 9 years ago
parent
commit
0c63276218

+ 3 - 0
src/optimization/analyzerTexprTransformer.ml

@@ -455,6 +455,9 @@ let rec func ctx bb tf t p =
 		| TReturn None ->
 			add_cfg_edge bb bb_exit CFGGoto;
 			add_terminator bb e
+		| TReturn (Some e1) when ExtType.is_void (follow e1.etype) ->
+			let bb = block_element bb e1 in
+			block_element bb (mk (TReturn None) t_dynamic e.epos)
 		| TReturn (Some e1) ->
 			begin try
 				let mk_return e1 = mk (TReturn (Some e1)) t_dynamic e.epos in

+ 8 - 0
tests/unit/src/unit/issues/Issue5027.hx

@@ -0,0 +1,8 @@
+package unit.issues;
+
+class Issue5027 extends Test {
+	function test() {
+		var f:Void->Void = function() return null;
+		f();
+	}
+}