Browse Source

fix some OCaml 4.03 warnings

Simon Krajewski 8 years ago
parent
commit
61bccc61b8

+ 1 - 1
src/generators/codegen.ml

@@ -855,7 +855,7 @@ let interpolate_code com code tl f_string f_expr p =
 				let expr = Array.get exprs (int_of_string n) in
 				f_expr expr;
 			with
-			| Failure "int_of_string" ->
+			| Failure _ ->
 				f_string ("{" ^ n ^ "}");
 			| Invalid_argument _ ->
 				err ("Out-of-bounds special parameter: " ^ n)

+ 5 - 5
src/generators/gencommon/castDetect.ml

@@ -324,7 +324,7 @@ let rec handle_cast gen e real_to_t real_from_t =
 	in
 
 	let e = { e with etype = real_from_t } in
-	if try fast_eq real_to_t real_from_t with Invalid_argument("List.for_all2") -> false then e else
+	if try fast_eq real_to_t real_from_t with Invalid_argument _ -> false then e else
 	match real_to_t, real_from_t with
 		(* string is the only type that can be implicitly converted from any other *)
 		| TInst( { cl_path = ([], "String") }, []), TInst( { cl_path = ([], "String") }, [] ) ->
@@ -446,7 +446,7 @@ let rec handle_cast gen e real_to_t real_from_t =
 					List.iter2 (type_eq gen (if gen.gallow_tp_dynamic_conversion then EqRightDynamic else EqStrict)) params_from params_to;
 					e
 				with
-					| Invalid_argument("List.iter2") ->
+					| Invalid_argument _ ->
 						(*
 							this is a hack for RealTypeParams. Since there is no way at this stage to know if the class is the actual
 							EnumsToClass derived from the enum, we need to imply from possible ArgumentErrors (because of RealTypeParams interfaces),
@@ -496,7 +496,7 @@ let rec handle_cast gen e real_to_t real_from_t =
 				mk_cast true to_t e
 		| TFun(args, ret), TFun(args2, ret2) ->
 			let get_args = List.map (fun (_,_,t) -> t) in
-			(try List.iter2 (type_eq gen (EqBothDynamic)) (ret :: get_args args) (ret2 :: get_args args2); e with | Unify_error _ | Invalid_argument("List.iter2") -> mk_cast true to_t e)
+			(try List.iter2 (type_eq gen (EqBothDynamic)) (ret :: get_args args) (ret2 :: get_args args2); e with | Unify_error _ | Invalid_argument _ -> mk_cast true to_t e)
 		| _, _ ->
 			do_unsafe_cast ()
 
@@ -686,7 +686,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 				| Unify_error el ->
 						(* List.iter (fun el -> gen.gcon.warning (Typecore.unify_error_msg (print_context()) el) pos) el; *)
 						gen.gcon.warning ("This expression may be invalid") pos
-				| Invalid_argument("List.map2") ->
+				| Invalid_argument _ ->
 						gen.gcon.warning ("This expression may be invalid") pos
 			);
 
@@ -821,7 +821,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 							{ e1 with eexpr = TField(!ef, f) },
 							elist);
 					}, elist
-				with | Invalid_argument("List.map2") ->
+				with Invalid_argument _ ->
 					gen.gcon.warning ("This expression may be invalid" ) ecall.epos;
 					{ ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist) }, elist
 				in

+ 1 - 1
src/generators/gencommon/overloadingConstructor.ml

@@ -97,7 +97,7 @@ let replace_super_call com c tl with_params me p follow_type =
 					with Unify_error _ ->
 						false
 					) args with_params
-				with Invalid_argument("List.for_all2") ->
+				with Invalid_argument _ ->
 					false
 			) (cf :: cf.cf_overloads)
 		with Not_found ->

+ 3 - 1
src/generators/genpy.ml

@@ -1264,7 +1264,9 @@ module Printer = struct
 					Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2)
 				| TDynamic _, TDynamic _ ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
-				| TDynamic _, x | x, TDynamic _ when is_list_or_anon x ->
+				| TDynamic _, x when is_list_or_anon x ->
+					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
+				| x, TDynamic _ when is_list_or_anon x ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
 				| _,_ -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (snd ops) (print_expr pctx e2))
 			| TBinop(OpMod,e1,e2) when (is_type1 "" "Int")(e1.etype) && (is_type1 "" "Int")(e2.etype) ->

+ 1 - 1
src/generators/genswf.ml

@@ -260,7 +260,7 @@ let build_swf9 com file swc =
 		if String.length file > 5 && String.sub file 0 5 = "data:" then
 			String.sub file 5 (String.length file - 5)
 		else
-			(try Std.input_file ~bin:true file with Invalid_argument("String.create") -> abort "File is too big (max 16MB allowed)" p | _  -> abort "File not found" p)
+			(try Std.input_file ~bin:true file with Invalid_argument _ -> abort "File is too big (max 16MB allowed)" p | _  -> abort "File not found" p)
 	in
 	let bmp = List.fold_left (fun acc t ->
 		match t with

+ 2 - 2
src/typing/java.ml

@@ -546,7 +546,7 @@ and compatible_tparams p1 p2 = try match p1, p2 with
 		List.for_all2 compatible_param p1 p2
 	| _, _ ->
 		List.for_all2 compatible_param p1 p2
-	with | Invalid_argument("List.for_all2") -> false
+	with | Invalid_argument _ -> false
 
 let get_adapted_sig f f2 = match f.jf_types with
 	| [] ->
@@ -588,7 +588,7 @@ let jclass_with_params com cls params = try
 			csuper = japply_params jparams cls.csuper;
 			cinterfaces = List.map (japply_params jparams) cls.cinterfaces;
 		}
-	with Invalid_argument("List.map2") ->
+	with Invalid_argument _ ->
 		if com.verbose then prerr_endline ("Differing parameters for class: " ^ s_type_path cls.cpath);
 		cls
 

+ 1 - 1
src/typing/overloads.ml

@@ -36,7 +36,7 @@ let same_overload_args ?(get_vmtype) t1 t2 f1 f2 =
 			(try
 				List.for_all2 (fun (_,_,t1) (_,_,t2) ->
 				same_arg t1 t2) a1 a2
-			with | Invalid_argument("List.for_all2") ->
+			with Invalid_argument _ ->
 				false)
 		| _ -> assert false
 

+ 2 - 1
src/typing/typer.ml

@@ -2158,7 +2158,8 @@ and type_binop2 ctx op (e1 : texpr) (e2 : Ast.expr) is_assign_op wt p =
 		| KDyn , KInt | KDyn , KFloat | KDyn , KString -> ()
 		| KInt , KDyn | KFloat , KDyn | KString , KDyn -> ()
 		| KDyn , KDyn -> ()
-		| KParam _ , x | x , KParam _ when x <> KString && x <> KOther -> ()
+		| KParam _ , x when x <> KString && x <> KOther -> ()
+		| x , KParam _ when x <> KString && x <> KOther -> ()
 		| KAbstract _,_
 		| _,KAbstract _
 		| KDyn , KUnk