瀏覽代碼

disallow equality checks where Void types are involved

Simon Krajewski 13 年之前
父節點
當前提交
757e85f7a4
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      typer.ml

+ 3 - 1
typer.ml

@@ -1282,7 +1282,9 @@ let rec type_binop ctx op e1 e2 p =
 	| OpEq
 	| OpNotEq ->
 		(try
-			unify_raise ctx e1.etype e2.etype p
+			unify_raise ctx e1.etype e2.etype p;
+			(* we only have to check one type here, because unification fails if one is Void and the other is not *)
+			(match follow e2.etype with TAbstract({a_path=[],"Void"},_) -> error "Cannot compare Void" p | _ -> ())
 		with
 			Error (Unify _,_) -> unify ctx e2.etype e1.etype p);
 		mk_op ctx.t.tbool