Browse Source

prevent constructor return value.

Nicolas Cannasse 18 years ago
parent
commit
db4db7d838
1 changed files with 4 additions and 0 deletions
  1. 4 0
      typer.ml

+ 4 - 0
typer.ml

@@ -2106,6 +2106,10 @@ let init_class ctx c p herits fields =
 			let t = TFun (args,ret) in
 			let stat = List.mem AStatic access in
 			let constr = (name = "new") in
+			if constr then (match f.f_type with 
+				| None | Some (TPNormal { tpackage = []; tname = "Void" }) -> ()
+				| _ -> error "A class constructor can't have a return value" p
+			);
 			let cf = {
 				cf_name = name;
 				cf_doc = doc;