瀏覽代碼

use with_type information for if/else instead of unify_min (fixed issue #1702)

Nicolas Cannasse 12 年之前
父節點
當前提交
ca6d5a5c69
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      typer.ml

+ 8 - 1
typer.ml

@@ -2654,7 +2654,14 @@ and type_expr ctx (e,p) (with_type:with_type) =
 				mk (TIf (e,e1,None)) ctx.t.tvoid p
 		| Some e2 ->
 			let e2 = type_expr ctx e2 with_type in
-			let t = if with_type = NoValue then ctx.t.tvoid else unify_min ctx [e1; e2] in
+			let t = match with_type with
+				| NoValue -> ctx.t.tvoid
+				| Value -> unify_min ctx [e1; e2]
+				| WithType t | WithTypeResume t ->
+					unify ctx e1.etype t e1.epos;
+					unify ctx e2.etype t e2.epos;
+					t
+			in
 			mk (TIf (e,e1,Some e2)) t p)
 	| EWhile (cond,e,NormalWhile) ->
 		let old_loop = ctx.in_loop in