Browse Source

disallow equality checks where Void types are involved

Simon Krajewski 12 years ago
parent
commit
757e85f7a4
1 changed files with 3 additions and 1 deletions
  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