From 732be46cad4ac7edef88886d3612a71c726b54a7 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sun, 4 Feb 2024 08:10:27 +0100 Subject: [PATCH] remove all "Something went wrong" errors --- src/generators/genjvm.ml | 2 +- src/generators/genshared.ml | 9 +++++---- src/macro/eval/evalEmitter.ml | 4 ++-- src/macro/eval/evalExceptions.ml | 6 +++--- src/macro/eval/evalJit.ml | 2 +- src/typing/matcher/texprConverter.ml | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/generators/genjvm.ml b/src/generators/genjvm.ml index ca7cbfcb533..ea90c8c5868 100644 --- a/src/generators/genjvm.ml +++ b/src/generators/genjvm.ml @@ -1675,7 +1675,7 @@ class texpr_to_jvm info.super_call_fields <- tl; hd | _ -> - Error.raise_typing_error "Something went wrong" e1.epos + Error.raise_typing_error "Could not find field information for super call, please report this" e1.epos in let kind = get_construction_mode c cf in begin match kind with diff --git a/src/generators/genshared.ml b/src/generators/genshared.ml index aa6c7bab126..9aa67cea7b3 100644 --- a/src/generators/genshared.ml +++ b/src/generators/genshared.ml @@ -128,14 +128,15 @@ object(self) | None -> die "" __LOC__ | Some(c,_) -> c,cf in - let rec promote_this_before_super c cf = match self#get_field_info cf.cf_meta with - | None -> failwith "Something went wrong" + let rec promote_this_before_super c cf p = match self#get_field_info cf.cf_meta with + | None -> + Error.raise_typing_error (Printf.sprintf "Could not determine field information for %s in a this-before-super case, please report this" cf.cf_name) p | Some info -> if not info.has_this_before_super then begin make_haxe cf; (* print_endline (Printf.sprintf "promoted this_before_super to %s.new : %s" (s_type_path c.cl_path) (s_type (print_context()) cf.cf_type)); *) info.has_this_before_super <- true; - List.iter (fun (c,cf) -> promote_this_before_super c cf) info.super_call_fields + List.iter (fun (c,cf) -> promote_this_before_super c cf p) info.super_call_fields end in let rec loop e = @@ -153,7 +154,7 @@ object(self) (* print_endline (Printf.sprintf "inferred this_before_super on %s.new : %s" (s_type_path c.cl_path) (s_type (print_context()) cf.cf_type)); *) end; let c,cf = find_super_ctor el in - if !this_before_super then promote_this_before_super c cf; + if !this_before_super then promote_this_before_super c cf e.epos; DynArray.add super_call_fields (c,cf); | _ -> Type.iter loop e diff --git a/src/macro/eval/evalEmitter.ml b/src/macro/eval/evalEmitter.ml index 56de9326e61..7663674aac7 100644 --- a/src/macro/eval/evalEmitter.ml +++ b/src/macro/eval/evalEmitter.ml @@ -754,8 +754,8 @@ let process_arguments fl vl env = loop fl [] | [],[] -> () - | _ -> - exc_string "Something went wrong" + | l1,l2 -> + exc_string (Printf.sprintf "Bad number of arguments: %i vs. %i" (List.length l1) (List.length l2)) in loop fl vl [@@inline] diff --git a/src/macro/eval/evalExceptions.ml b/src/macro/eval/evalExceptions.ml index f1c146d98d6..b3954e20692 100644 --- a/src/macro/eval/evalExceptions.ml +++ b/src/macro/eval/evalExceptions.ml @@ -137,7 +137,7 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p = in (Error.Custom (value_string v1), v2) end else - Error.raise_typing_error "Something went wrong" null_pos + Error.raise_typing_error (Printf.sprintf "Unexpected value where haxe.macro.Error was expected: %s" (s_value 0 v).sstring) null_pos ) (EvalArray.to_list sub) | _ -> [] in @@ -165,8 +165,8 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p = | [] -> Error.raise_msg s.sstring p | _ -> Error.raise_error (Error.make_error ~sub:(List.map (fun (msg,p) -> Error.make_error msg p) stack) (Error.Custom s.sstring) p) ); - | _ -> - Error.raise_typing_error "Something went wrong" null_pos + | v -> + Error.raise_typing_error (Printf.sprintf "Invalid exception value where string was expected: %s" (s_value 0 v).sstring) null_pos end else begin (* Careful: We have to get the message before resetting the context because toString() might access it. *) let stack = match eval_stack with diff --git a/src/macro/eval/evalJit.ml b/src/macro/eval/evalJit.ml index d2c21a539a1..89c428641ce 100644 --- a/src/macro/eval/evalJit.ml +++ b/src/macro/eval/evalJit.ml @@ -235,7 +235,7 @@ and jit_expr jit return e = List.iter (fun var -> ignore(get_capture_slot jit var)) jit_closure.captures_outside_scope; let captures = ExtList.List.filter_map (fun (i,vid,declared) -> if declared then None - else Some (i,fst (try Hashtbl.find jit.captures vid with Not_found -> Error.raise_typing_error "Something went wrong" e.epos)) + else Some (i,fst (try Hashtbl.find jit.captures vid with Not_found -> Error.raise_typing_error (Printf.sprintf "Could not find capture variable %i" vid) e.epos)) ) captures in let mapping = Array.of_list captures in emit_closure ctx mapping eci hasret exec fl diff --git a/src/typing/matcher/texprConverter.ml b/src/typing/matcher/texprConverter.ml index 87f92657803..dfe269d63f9 100644 --- a/src/typing/matcher/texprConverter.ml +++ b/src/typing/matcher/texprConverter.ml @@ -25,7 +25,7 @@ let constructor_to_texpr ctx con = | ConArray i -> make_int ctx.com.basic i p | ConTypeExpr mt -> TyperBase.type_module_type ctx mt p | ConStatic(c,cf) -> make_static_field c cf p - | ConFields _ -> raise_typing_error "Something went wrong" p + | ConFields _ -> raise_typing_error "Unexpected matching on ConFields, please report this" p let s_subject v_lookup s e = let rec loop top s e = match e.eexpr with