Skip to content

Commit

Permalink
fix some OCaml 4.03 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed May 1, 2017
1 parent 7cf0957 commit 61bccc6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/generators/codegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/generators/gencommon/castDetect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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") }, [] ) ->
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 ()

Expand Down Expand Up @@ -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
);

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/generators/gencommon/overloadingConstructor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
4 changes: 3 additions & 1 deletion src/generators/genpy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
2 changes: 1 addition & 1 deletion src/generators/genswf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/typing/java.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
| [] ->
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/typing/overloads.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61bccc6

Please sign in to comment.