浏览代码

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