|
@@ -53,8 +53,6 @@ type display_field_kind =
|
|
exception DisplayFields of (string * t * display_field_kind option * documentation) list
|
|
exception DisplayFields of (string * t * display_field_kind option * documentation) list
|
|
exception DisplayToplevel of identifier_type list
|
|
exception DisplayToplevel of identifier_type list
|
|
|
|
|
|
-exception WithTypeError of unify_error list * pos
|
|
|
|
-
|
|
|
|
type access_kind =
|
|
type access_kind =
|
|
| AKNo of string
|
|
| AKNo of string
|
|
| AKExpr of texpr
|
|
| AKExpr of texpr
|
|
@@ -670,7 +668,10 @@ let is_forced_inline c cf =
|
|
| _ -> false
|
|
| _ -> false
|
|
|
|
|
|
let rec unify_call_args' ctx el args r callp inline force_inline =
|
|
let rec unify_call_args' ctx el args r callp inline force_inline =
|
|
|
|
+ let in_call_args = ctx.in_call_args in
|
|
|
|
+ ctx.in_call_args <- true;
|
|
let call_error err p =
|
|
let call_error err p =
|
|
|
|
+ ctx.in_call_args <- in_call_args;
|
|
raise (Error (Call_error err,p))
|
|
raise (Error (Call_error err,p))
|
|
in
|
|
in
|
|
let arg_error ul name opt p =
|
|
let arg_error ul name opt p =
|
|
@@ -696,8 +697,8 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
|
|
in
|
|
in
|
|
(* let force_inline, is_extern = match cf with Some(TInst(c,_),f) -> is_forced_inline (Some c) f, c.cl_extern | _ -> false, false in *)
|
|
(* let force_inline, is_extern = match cf with Some(TInst(c,_),f) -> is_forced_inline (Some c) f, c.cl_extern | _ -> false, false in *)
|
|
let type_against t e =
|
|
let type_against t e =
|
|
- let e = type_expr ctx e (WithTypeResume t) in
|
|
|
|
- (try Codegen.AbstractCast.cast_or_unify_raise ctx t e e.epos with Error (Unify l,p) -> raise (WithTypeError (l,p)));
|
|
|
|
|
|
+ let e = type_expr ctx e (WithType t) in
|
|
|
|
+ (try Codegen.AbstractCast.cast_or_unify_raise ctx t e e.epos with Error (Unify l,p) -> ctx.in_call_args <- in_call_args; raise (WithTypeError (l,p)))
|
|
in
|
|
in
|
|
let rec loop el args = match el,args with
|
|
let rec loop el args = match el,args with
|
|
| [],[] ->
|
|
| [],[] ->
|
|
@@ -739,6 +740,7 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
|
|
end
|
|
end
|
|
in
|
|
in
|
|
let el = loop el args in
|
|
let el = loop el args in
|
|
|
|
+ ctx.in_call_args <- in_call_args;
|
|
el,TFun(args,r)
|
|
el,TFun(args,r)
|
|
|
|
|
|
let unify_call_args ctx el args r p inline force_inline =
|
|
let unify_call_args ctx el args r p inline force_inline =
|
|
@@ -807,9 +809,9 @@ let unify_field_call ctx fa el args ret p inline =
|
|
candidate :: candidates,failures
|
|
candidate :: candidates,failures
|
|
end else
|
|
end else
|
|
[candidate],[]
|
|
[candidate],[]
|
|
- with Error (Call_error _,_) as err ->
|
|
|
|
|
|
+ with Error ((Call_error _ as err),p) ->
|
|
let candidates,failures = loop candidates in
|
|
let candidates,failures = loop candidates in
|
|
- candidates,err :: failures
|
|
|
|
|
|
+ candidates,(cf,err,p) :: failures
|
|
end
|
|
end
|
|
in
|
|
in
|
|
match candidates with
|
|
match candidates with
|
|
@@ -818,9 +820,19 @@ let unify_field_call ctx fa el args ret p inline =
|
|
List.map fst el,tf,mk_call
|
|
List.map fst el,tf,mk_call
|
|
| _ ->
|
|
| _ ->
|
|
let candidates,failures = loop candidates in
|
|
let candidates,failures = loop candidates in
|
|
- let fail () = match List.rev failures with
|
|
|
|
- | err :: _ -> raise err
|
|
|
|
- | _ -> assert false
|
|
|
|
|
|
+ let fail () =
|
|
|
|
+ let failures = List.map (fun (cf,err,p) -> cf,error_msg err,p) failures in
|
|
|
|
+ begin match failures with
|
|
|
|
+ | (_,msg,p) :: failures when List.for_all (fun (_,msg2,_) -> msg = msg2) failures ->
|
|
|
|
+ error msg p
|
|
|
|
+ | _ ->
|
|
|
|
+ display_error ctx "Could not find a suitable overload, reasons follow" p;
|
|
|
|
+ List.iter (fun (cf,msg,p2) ->
|
|
|
|
+ display_error ctx ("Overload resolution failed for " ^ (s_type (print_context()) cf.cf_type)) p;
|
|
|
|
+ display_error ctx msg p2;
|
|
|
|
+ ) failures;
|
|
|
|
+ error "End of overload failure reasons" p
|
|
|
|
+ end
|
|
in
|
|
in
|
|
if is_overload && ctx.com.config.pf_overload then begin match Codegen.Overloads.reduce_compatible candidates with
|
|
if is_overload && ctx.com.config.pf_overload then begin match Codegen.Overloads.reduce_compatible candidates with
|
|
| [] -> fail()
|
|
| [] -> fail()
|
|
@@ -1829,7 +1841,6 @@ let unify_int ctx e k =
|
|
in
|
|
in
|
|
begin match with_type with
|
|
begin match with_type with
|
|
| WithType t -> unify ctx ret t p
|
|
| WithType t -> unify ctx ret t p
|
|
- | WithTypeResume t -> (try unify_raise ctx ret t p with Error (Unify l,_) -> raise (WithTypeError(l,p)))
|
|
|
|
| _ -> ()
|
|
| _ -> ()
|
|
end;
|
|
end;
|
|
let el,_ = unify_call_args ctx el args ret p false false in
|
|
let el,_ = unify_call_args ctx el args ret p false false in
|
|
@@ -2072,7 +2083,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
|
|
(* If the with_type is an abstract which has exactly one applicable @:op method, we can promote it
|
|
(* If the with_type is an abstract which has exactly one applicable @:op method, we can promote it
|
|
to the individual arguments (issue #2786). *)
|
|
to the individual arguments (issue #2786). *)
|
|
let wt = match with_type with
|
|
let wt = match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
begin match follow t with
|
|
begin match follow t with
|
|
| TAbstract(a,_) ->
|
|
| TAbstract(a,_) ->
|
|
begin match List.filter (fun (o,_) -> o = OpAssignOp(op) || o == op) a.a_ops with
|
|
begin match List.filter (fun (o,_) -> o = OpAssignOp(op) || o == op) a.a_ops with
|
|
@@ -2807,11 +2818,6 @@ and type_vars ctx vl p in_block =
|
|
let e = mk (TBlock (List.map (fun (v,e) -> (mk (TVar (v,e)) ctx.t.tvoid p)) vl)) ctx.t.tvoid p in
|
|
let e = mk (TBlock (List.map (fun (v,e) -> (mk (TVar (v,e)) ctx.t.tvoid p)) vl)) ctx.t.tvoid p in
|
|
mk (TMeta((Meta.MergeBlock,[],p), e)) e.etype e.epos
|
|
mk (TMeta((Meta.MergeBlock,[],p), e)) e.etype e.epos
|
|
|
|
|
|
-and with_type_error ctx with_type msg p =
|
|
|
|
- match with_type with
|
|
|
|
- | WithTypeResume _ -> raise (WithTypeError ([Unify_custom msg],p))
|
|
|
|
- | _ -> display_error ctx msg p
|
|
|
|
-
|
|
|
|
and format_string ctx s p =
|
|
and format_string ctx s p =
|
|
let e = ref None in
|
|
let e = ref None in
|
|
let pmin = ref p.pmin in
|
|
let pmin = ref p.pmin in
|
|
@@ -2947,7 +2953,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
acc_get ctx (type_ident_raise ~imported_enums:false ctx s p MGet) p
|
|
acc_get ctx (type_ident_raise ~imported_enums:false ctx s p MGet) p
|
|
with Not_found -> try
|
|
with Not_found -> try
|
|
(match with_type with
|
|
(match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
(match follow t with
|
|
(match follow t with
|
|
| TEnum (e,pl) ->
|
|
| TEnum (e,pl) ->
|
|
(try
|
|
(try
|
|
@@ -2956,7 +2962,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
mk (fast_enum_field e ef p) (enum_field_type ctx e ef pl monos p) p
|
|
mk (fast_enum_field e ef p) (enum_field_type ctx e ef pl monos p) p
|
|
with Not_found ->
|
|
with Not_found ->
|
|
if ctx.untyped then raise Not_found;
|
|
if ctx.untyped then raise Not_found;
|
|
- with_type_error ctx with_type (string_error s e.e_names ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path e.e_path)) p;
|
|
|
|
|
|
+ raise_or_display_message ctx (string_error s e.e_names ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path e.e_path)) p;
|
|
mk (TConst TNull) t p)
|
|
mk (TConst TNull) t p)
|
|
| TAbstract (a,pl) when has_meta Meta.Enum a.a_meta ->
|
|
| TAbstract (a,pl) when has_meta Meta.Enum a.a_meta ->
|
|
let cimpl = (match a.a_impl with None -> assert false | Some c -> c) in
|
|
let cimpl = (match a.a_impl with None -> assert false | Some c -> c) in
|
|
@@ -2965,7 +2971,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
acc_get ctx (type_field ctx (mk (TTypeExpr (TClassDecl cimpl)) (TAnon { a_fields = PMap.add cf.cf_name cf PMap.empty; a_status = ref (Statics cimpl) }) p) s p MGet) p
|
|
acc_get ctx (type_field ctx (mk (TTypeExpr (TClassDecl cimpl)) (TAnon { a_fields = PMap.add cf.cf_name cf PMap.empty; a_status = ref (Statics cimpl) }) p) s p MGet) p
|
|
with Not_found ->
|
|
with Not_found ->
|
|
if ctx.untyped then raise Not_found;
|
|
if ctx.untyped then raise Not_found;
|
|
- with_type_error ctx with_type (string_error s (List.map (fun f -> f.cf_name) cimpl.cl_ordered_statics) ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path a.a_path)) p;
|
|
|
|
|
|
+ raise_or_display_message ctx (string_error s (List.map (fun f -> f.cf_name) cimpl.cl_ordered_statics) ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path a.a_path)) p;
|
|
mk (TConst TNull) t p)
|
|
mk (TConst TNull) t p)
|
|
| _ -> raise Not_found)
|
|
| _ -> raise Not_found)
|
|
| _ ->
|
|
| _ ->
|
|
@@ -2999,7 +3005,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
| EObjectDecl fl ->
|
|
| EObjectDecl fl ->
|
|
let dynamic_parameter = ref None in
|
|
let dynamic_parameter = ref None in
|
|
let a = (match with_type with
|
|
let a = (match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
(match follow t with
|
|
(match follow t with
|
|
| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
|
|
| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
|
|
(* issues with https://github.com/HaxeFoundation/haxe/issues/3437 *)
|
|
(* issues with https://github.com/HaxeFoundation/haxe/issues/3437 *)
|
|
@@ -3046,7 +3052,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
if PMap.mem n !fields then error ("Duplicate field in object declaration : " ^ n) p;
|
|
if PMap.mem n !fields then error ("Duplicate field in object declaration : " ^ n) p;
|
|
let e = try
|
|
let e = try
|
|
let t = (match !dynamic_parameter with Some t -> t | None -> (PMap.find n a.a_fields).cf_type) in
|
|
let t = (match !dynamic_parameter with Some t -> t | None -> (PMap.find n a.a_fields).cf_type) in
|
|
- let e = type_expr ctx e (match with_type with WithTypeResume _ -> WithTypeResume t | _ -> WithType t) in
|
|
|
|
|
|
+ let e = type_expr ctx e (WithType t) in
|
|
let e = Codegen.AbstractCast.cast_or_unify ctx t e p in
|
|
let e = Codegen.AbstractCast.cast_or_unify ctx t e p in
|
|
(try type_eq EqStrict e.etype t; e with Unify_error _ -> mk (TCast (e,None)) t e.epos)
|
|
(try type_eq EqStrict e.etype t; e with Unify_error _ -> mk (TCast (e,None)) t e.epos)
|
|
with Not_found ->
|
|
with Not_found ->
|
|
@@ -3064,18 +3070,13 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
) fl in
|
|
) fl in
|
|
let t = (TAnon { a_fields = !fields; a_status = ref Const }) in
|
|
let t = (TAnon { a_fields = !fields; a_status = ref Const }) in
|
|
if not ctx.untyped then begin
|
|
if not ctx.untyped then begin
|
|
- let unify_error l p =
|
|
|
|
- match with_type with
|
|
|
|
- | WithTypeResume _ -> raise (WithTypeError (l,p))
|
|
|
|
- | _ -> raise (Error (Unify l,p))
|
|
|
|
- in
|
|
|
|
(match PMap.foldi (fun n cf acc -> if not (Meta.has Meta.Optional cf.cf_meta) && not (PMap.mem n !fields) then n :: acc else acc) a.a_fields [] with
|
|
(match PMap.foldi (fun n cf acc -> if not (Meta.has Meta.Optional cf.cf_meta) && not (PMap.mem n !fields) then n :: acc else acc) a.a_fields [] with
|
|
| [] -> ()
|
|
| [] -> ()
|
|
- | [n] -> unify_error [Unify_custom ("Object requires field " ^ n)] p
|
|
|
|
- | nl -> unify_error [Unify_custom ("Object requires fields: " ^ (String.concat ", " nl))] p);
|
|
|
|
|
|
+ | [n] -> raise_or_display ctx [Unify_custom ("Object requires field " ^ n)] p
|
|
|
|
+ | nl -> raise_or_display ctx [Unify_custom ("Object requires fields: " ^ (String.concat ", " nl))] p);
|
|
(match !extra_fields with
|
|
(match !extra_fields with
|
|
| [] -> ()
|
|
| [] -> ()
|
|
- | _ -> unify_error (List.map (fun n -> has_extra_field t n) !extra_fields) p);
|
|
|
|
|
|
+ | _ -> raise_or_display ctx (List.map (fun n -> has_extra_field t n) !extra_fields) p);
|
|
end;
|
|
end;
|
|
if !(a.a_status) <> Const then a.a_status := Closed;
|
|
if !(a.a_status) <> Const then a.a_status := Closed;
|
|
mk (TObjectDecl fl) t p)
|
|
mk (TObjectDecl fl) t p)
|
|
@@ -3106,7 +3107,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
mk (TLocal v) v.v_type p;
|
|
mk (TLocal v) v.v_type p;
|
|
]) v.v_type p
|
|
]) v.v_type p
|
|
| EArrayDecl ((EBinop(OpArrow,_,_),_) as e1 :: el) ->
|
|
| EArrayDecl ((EBinop(OpArrow,_,_),_) as e1 :: el) ->
|
|
- let (tkey,tval,has_type),resume =
|
|
|
|
|
|
+ let (tkey,tval,has_type) =
|
|
let get_map_params t = match follow t with
|
|
let get_map_params t = match follow t with
|
|
| TAbstract({a_path=[],"Map"},[tk;tv]) -> tk,tv,true
|
|
| TAbstract({a_path=[],"Map"},[tk;tv]) -> tk,tv,true
|
|
| TInst({cl_path=["haxe";"ds"],"IntMap"},[tv]) -> ctx.t.tint,tv,true
|
|
| TInst({cl_path=["haxe";"ds"],"IntMap"},[tv]) -> ctx.t.tint,tv,true
|
|
@@ -3115,15 +3116,10 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
| _ -> mk_mono(),mk_mono(),false
|
|
| _ -> mk_mono(),mk_mono(),false
|
|
in
|
|
in
|
|
match with_type with
|
|
match with_type with
|
|
- | WithType t -> get_map_params t,false
|
|
|
|
- | WithTypeResume t -> get_map_params t,true
|
|
|
|
- | _ -> (mk_mono(),mk_mono(),false),false
|
|
|
|
|
|
+ | WithType t -> get_map_params t
|
|
|
|
+ | _ -> (mk_mono(),mk_mono(),false)
|
|
in
|
|
in
|
|
let keys = Hashtbl.create 0 in
|
|
let keys = Hashtbl.create 0 in
|
|
- let unify_with_resume ctx e t p =
|
|
|
|
- if resume then try Codegen.AbstractCast.cast_or_unify_raise ctx t e p with Error (Unify l,p) -> raise (WithTypeError(l,p))
|
|
|
|
- else Codegen.AbstractCast.cast_or_unify ctx t e p
|
|
|
|
- in
|
|
|
|
let check_key e_key =
|
|
let check_key e_key =
|
|
try
|
|
try
|
|
let p = Hashtbl.find keys e_key.eexpr in
|
|
let p = Hashtbl.find keys e_key.eexpr in
|
|
@@ -3141,9 +3137,9 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
let el_k,el_v = List.fold_left (fun (el_k,el_v) (e1,e2) ->
|
|
let el_k,el_v = List.fold_left (fun (el_k,el_v) (e1,e2) ->
|
|
let e1 = type_expr ctx e1 (WithType tkey) in
|
|
let e1 = type_expr ctx e1 (WithType tkey) in
|
|
check_key e1;
|
|
check_key e1;
|
|
- let e1 = unify_with_resume ctx e1 tkey e1.epos in
|
|
|
|
|
|
+ let e1 = Codegen.AbstractCast.cast_or_unify ctx tkey e1 e1.epos in
|
|
let e2 = type_expr ctx e2 (WithType tval) in
|
|
let e2 = type_expr ctx e2 (WithType tval) in
|
|
- let e2 = unify_with_resume ctx e2 tval e2.epos in
|
|
|
|
|
|
+ let e2 = Codegen.AbstractCast.cast_or_unify ctx tval e2 e2.epos in
|
|
(e1 :: el_k,e2 :: el_v)
|
|
(e1 :: el_k,e2 :: el_v)
|
|
) ([],[]) el_kv in
|
|
) ([],[]) el_kv in
|
|
el_k,el_v,tkey,tval
|
|
el_k,el_v,tkey,tval
|
|
@@ -3156,7 +3152,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
) ([],[]) el_kv in
|
|
) ([],[]) el_kv in
|
|
let unify_min_resume el = try
|
|
let unify_min_resume el = try
|
|
unify_min_raise ctx el
|
|
unify_min_raise ctx el
|
|
- with Error (Unify l,p) when resume ->
|
|
|
|
|
|
+ with Error (Unify l,p) when ctx.in_call_args ->
|
|
raise (WithTypeError(l,p))
|
|
raise (WithTypeError(l,p))
|
|
in
|
|
in
|
|
let tkey = unify_min_resume el_k in
|
|
let tkey = unify_min_resume el_k in
|
|
@@ -3180,7 +3176,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
mk (TBlock el) tmap p
|
|
mk (TBlock el) tmap p
|
|
| EArrayDecl el ->
|
|
| EArrayDecl el ->
|
|
let tp = (match with_type with
|
|
let tp = (match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
(match follow t with
|
|
(match follow t with
|
|
| TInst ({ cl_path = [],"Array" },[tp]) ->
|
|
| TInst ({ cl_path = [],"Array" },[tp]) ->
|
|
(match follow tp with
|
|
(match follow tp with
|
|
@@ -3210,10 +3206,8 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p
|
|
| Some t ->
|
|
| Some t ->
|
|
let el = List.map (fun e ->
|
|
let el = List.map (fun e ->
|
|
- let e = type_expr ctx e (match with_type with WithTypeResume _ -> WithTypeResume t | _ -> WithType t) in
|
|
|
|
- (match with_type with
|
|
|
|
- | WithTypeResume _ -> (try Codegen.AbstractCast.cast_or_unify_raise ctx t e p with Error (Unify l,p) -> raise (WithTypeError (l,p)))
|
|
|
|
- | _ -> Codegen.AbstractCast.cast_or_unify ctx t e p);
|
|
|
|
|
|
+ let e = type_expr ctx e (WithType t) in
|
|
|
|
+ Codegen.AbstractCast.cast_or_unify ctx t e p;
|
|
) el in
|
|
) el in
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p)
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p)
|
|
| EVars vl ->
|
|
| EVars vl ->
|
|
@@ -3275,18 +3269,11 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
let e1,e2,t = match with_type with
|
|
let e1,e2,t = match with_type with
|
|
| NoValue -> e1,e2,ctx.t.tvoid
|
|
| NoValue -> e1,e2,ctx.t.tvoid
|
|
| Value -> e1,e2,unify_min ctx [e1; e2]
|
|
| Value -> e1,e2,unify_min ctx [e1; e2]
|
|
- | WithType t | WithTypeResume t when (match follow t with TMono _ -> true | _ -> false) -> e1,e2,unify_min ctx [e1; e2]
|
|
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
- begin try
|
|
|
|
- let e1 = Codegen.AbstractCast.cast_or_unify_raise ctx t e1 e1.epos in
|
|
|
|
- let e2 = Codegen.AbstractCast.cast_or_unify_raise ctx t e2 e2.epos in
|
|
|
|
|
|
+ | WithType t when (match follow t with TMono _ -> true | _ -> false) -> e1,e2,unify_min ctx [e1; e2]
|
|
|
|
+ | WithType t ->
|
|
|
|
+ let e1 = Codegen.AbstractCast.cast_or_unify ctx t e1 e1.epos in
|
|
|
|
+ let e2 = Codegen.AbstractCast.cast_or_unify ctx t e2 e2.epos in
|
|
e1,e2,t
|
|
e1,e2,t
|
|
- with Error (Unify l,p) -> match with_type with
|
|
|
|
- | WithTypeResume _ -> raise (WithTypeError (l,p))
|
|
|
|
- | _ ->
|
|
|
|
- display_error ctx (error_msg (Unify l)) p;
|
|
|
|
- e1,e2,t
|
|
|
|
- end;
|
|
|
|
in
|
|
in
|
|
mk (TIf (e,e1,Some e2)) t p)
|
|
mk (TIf (e,e1,Some e2)) t p)
|
|
| EWhile (cond,e,NormalWhile) ->
|
|
| EWhile (cond,e,NormalWhile) ->
|
|
@@ -3408,7 +3395,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
| ECall (((EConst (Ident s),pc) as e),el) ->
|
|
| ECall (((EConst (Ident s),pc) as e),el) ->
|
|
(try
|
|
(try
|
|
let en,t = (match with_type with
|
|
let en,t = (match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
(match follow t with
|
|
(match follow t with
|
|
| TEnum (e,pl) -> e,t
|
|
| TEnum (e,pl) -> e,t
|
|
| _ -> raise Exit)
|
|
| _ -> raise Exit)
|
|
@@ -3436,7 +3423,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
with Not_found ->
|
|
with Not_found ->
|
|
restore();
|
|
restore();
|
|
if ctx.untyped then raise Exit; (* __js__, etc. *)
|
|
if ctx.untyped then raise Exit; (* __js__, etc. *)
|
|
- with_type_error ctx with_type (string_error s en.e_names ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path en.e_path)) p;
|
|
|
|
|
|
+ raise_or_display_message ctx (string_error s en.e_names ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path en.e_path)) p;
|
|
mk (TConst TNull) t p
|
|
mk (TConst TNull) t p
|
|
| err ->
|
|
| err ->
|
|
restore();
|
|
restore();
|
|
@@ -3481,7 +3468,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
with Codegen.Generic_Exception _ as exc ->
|
|
with Codegen.Generic_Exception _ as exc ->
|
|
(* If we have an expected type, just use that (issue #3804) *)
|
|
(* If we have an expected type, just use that (issue #3804) *)
|
|
begin match with_type with
|
|
begin match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
begin match follow t with
|
|
begin match follow t with
|
|
| TMono _ -> raise exc
|
|
| TMono _ -> raise exc
|
|
| t -> t
|
|
| t -> t
|
|
@@ -3556,7 +3543,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
s , c, t
|
|
s , c, t
|
|
) f.f_args in
|
|
) f.f_args in
|
|
(match with_type with
|
|
(match with_type with
|
|
- | WithType t | WithTypeResume t ->
|
|
|
|
|
|
+ | WithType t ->
|
|
let rec loop t =
|
|
let rec loop t =
|
|
(match follow t with
|
|
(match follow t with
|
|
| TFun (args2,tr) when List.length args2 = List.length args ->
|
|
| TFun (args2,tr) when List.length args2 = List.length args ->
|
|
@@ -3915,7 +3902,7 @@ and handle_display ctx e_ast iscall with_type p =
|
|
) c.cl_statics fields
|
|
) c.cl_statics fields
|
|
| TAnon a when PMap.is_empty a.a_fields ->
|
|
| TAnon a when PMap.is_empty a.a_fields ->
|
|
begin match with_type with
|
|
begin match with_type with
|
|
- | WithType t | WithTypeResume t -> get_fields t
|
|
|
|
|
|
+ | WithType t -> get_fields t
|
|
| _ -> a.a_fields
|
|
| _ -> a.a_fields
|
|
end
|
|
end
|
|
| TAnon a ->
|
|
| TAnon a ->
|
|
@@ -4639,7 +4626,7 @@ let make_macro_api ctx p =
|
|
);
|
|
);
|
|
Interp.get_expected_type = (fun() ->
|
|
Interp.get_expected_type = (fun() ->
|
|
match ctx.with_type_stack with
|
|
match ctx.with_type_stack with
|
|
- | (WithType t | WithTypeResume t) :: _ -> Some t
|
|
|
|
|
|
+ | (WithType t) :: _ -> Some t
|
|
| _ -> None
|
|
| _ -> None
|
|
);
|
|
);
|
|
Interp.get_call_arguments = (fun() ->
|
|
Interp.get_call_arguments = (fun() ->
|
|
@@ -5154,6 +5141,7 @@ let rec create com =
|
|
tthis = mk_mono();
|
|
tthis = mk_mono();
|
|
opened = [];
|
|
opened = [];
|
|
vthis = None;
|
|
vthis = None;
|
|
|
|
+ in_call_args = false;
|
|
on_error = (fun ctx msg p -> ctx.com.error msg p);
|
|
on_error = (fun ctx msg p -> ctx.com.error msg p);
|
|
} in
|
|
} in
|
|
ctx.g.std <- (try
|
|
ctx.g.std <- (try
|