Преглед на файлове

Improved error message on missing return when function return type is declared (fixed issue #722)

Simon Krajewski преди 13 години
родител
ревизия
331a0c5401
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      typeload.ml

+ 2 - 2
typeload.ml

@@ -586,8 +586,8 @@ let type_function ctx args ret fmode f p =
 	let have_ret = (try loop e; false with Exit -> true) in
 	if have_ret then
 		(try return_flow ctx e with Exit -> ())
-	else
-		unify ctx ret ctx.t.tvoid p;
+	else (try unify_raise ctx ret ctx.t.tvoid p
+		with Error(Unify _,_) -> display_error ctx ("Missing return: " ^ (s_type (print_context()) ret))  p);
 	let rec loop e =
 		match e.eexpr with
 		| TCall ({ eexpr = TConst TSuper },_) -> raise Exit