Переглянути джерело

[typer] remove unused ctx argument from unify_raise

Simon Krajewski 3 роки тому
батько
коміт
8be069bf31

+ 1 - 1
src/context/abstractCast.ml

@@ -102,7 +102,7 @@ and cast_or_unify_raise ctx ?(uctx=None) tleft eright p =
 	try
 	try
 		do_check_cast ctx uctx tleft eright p
 		do_check_cast ctx uctx tleft eright p
 	with Not_found ->
 	with Not_found ->
-		unify_raise_custom uctx ctx eright.etype tleft p;
+		unify_raise_custom uctx eright.etype tleft p;
 		eright
 		eright
 
 
 and cast_or_unify ctx tleft eright p =
 and cast_or_unify ctx tleft eright p =

+ 1 - 1
src/context/display/displayFields.ml

@@ -58,7 +58,7 @@ let collect_static_extensions ctx items e p =
 				let e = TyperBase.unify_static_extension ctx {e with etype = dup e.etype} t p in
 				let e = TyperBase.unify_static_extension ctx {e with etype = dup e.etype} t p in
 				List.iter2 (fun m tp -> match follow tp.ttp_type with
 				List.iter2 (fun m tp -> match follow tp.ttp_type with
 					| TInst ({ cl_kind = KTypeParameter constr },_) when constr <> [] ->
 					| TInst ({ cl_kind = KTypeParameter constr },_) when constr <> [] ->
-						List.iter (fun tc -> unify_raise ctx m (map tc) e.epos) constr
+						List.iter (fun tc -> unify_raise m (map tc) e.epos) constr
 					| _ -> ()
 					| _ -> ()
 				) monos f.cf_params;
 				) monos f.cf_params;
 				if not (can_access ctx c f true) || follow e.etype == t_dynamic && follow t != t_dynamic then
 				if not (can_access ctx c f true) || follow e.etype == t_dynamic && follow t != t_dynamic then

+ 1 - 1
src/context/typecore.ml

@@ -282,7 +282,7 @@ let unify ctx t1 t2 p =
 		Unify_error l ->
 		Unify_error l ->
 			raise_or_display ctx l p
 			raise_or_display ctx l p
 
 
-let unify_raise_custom uctx (ctx : typer) t1 t2 p =
+let unify_raise_custom uctx t1 t2 p =
 	try
 	try
 		Type.unify_custom uctx t1 t2
 		Type.unify_custom uctx t1 t2
 	with
 	with

+ 2 - 2
src/optimization/inline.ml

@@ -583,14 +583,14 @@ class inline_state ctx ethis params cf f p = object(self)
 		let e = Diagnostics.secure_generated_code ctx e in
 		let e = Diagnostics.secure_generated_code ctx e in
 		if has_params then begin
 		if has_params then begin
 			let mt = map_type cf.cf_type in
 			let mt = map_type cf.cf_type in
-			let unify_func () = unify_raise ctx mt (TFun (tl,tret)) p in
+			let unify_func () = unify_raise mt (TFun (tl,tret)) p in
 			(match follow ethis.etype with
 			(match follow ethis.etype with
 			| TAnon a -> (match !(a.a_status) with
 			| TAnon a -> (match !(a.a_status) with
 				| Statics {cl_kind = KAbstractImpl a } when has_class_field_flag cf CfImpl ->
 				| Statics {cl_kind = KAbstractImpl a } when has_class_field_flag cf CfImpl ->
 					if cf.cf_name <> "_new" then begin
 					if cf.cf_name <> "_new" then begin
 						(* the first argument must unify with a_this for abstract implementation functions *)
 						(* the first argument must unify with a_this for abstract implementation functions *)
 						let tb = (TFun(("",false,map_type a.a_this) :: (List.tl tl),tret)) in
 						let tb = (TFun(("",false,map_type a.a_this) :: (List.tl tl),tret)) in
-						unify_raise ctx mt tb p
+						unify_raise mt tb p
 					end
 					end
 				| _ -> unify_func())
 				| _ -> unify_func())
 			| _ -> unify_func());
 			| _ -> unify_func());

+ 1 - 1
src/typing/callUnification.ml

@@ -201,7 +201,7 @@ let unify_typed_args ctx tmap args el_typed call_pos =
 			List.rev acc_args,args
 			List.rev acc_args,args
 		| ((_,opt,t0) as arg) :: args,e :: el ->
 		| ((_,opt,t0) as arg) :: args,e :: el ->
 			begin try
 			begin try
-				unify_raise ctx (tmap e.etype) t0 e.epos;
+				unify_raise (tmap e.etype) t0 e.epos;
 			with Error(Unify _ as msg,p) ->
 			with Error(Unify _ as msg,p) ->
 				let call_error = Call_error(Could_not_unify msg) in
 				let call_error = Call_error(Could_not_unify msg) in
 				raise(Error(call_error,p))
 				raise(Error(call_error,p))

+ 1 - 1
src/typing/calls.ml

@@ -418,7 +418,7 @@ let array_access ctx e1 e2 mode p =
 				let pt = spawn_monomorph ctx p in
 				let pt = spawn_monomorph ctx p in
 				let t = ctx.t.tarray pt in
 				let t = ctx.t.tarray pt in
 				begin try
 				begin try
-					unify_raise ctx et t p
+					unify_raise et t p
 				with Error(Unify _,_) ->
 				with Error(Unify _,_) ->
 					if not ctx.untyped then begin
 					if not ctx.untyped then begin
 						let msg = if !has_abstract_array_access then
 						let msg = if !has_abstract_array_access then

+ 1 - 1
src/typing/forLoop.ml

@@ -107,7 +107,7 @@ module IterationKind = struct
 			let try_acc acc =
 			let try_acc acc =
 				let acc_expr = build_call ctx acc [] WithType.value e.epos in
 				let acc_expr = build_call ctx acc [] WithType.value e.epos in
 				try
 				try
-					unify_raise ctx acc_expr.etype t acc_expr.epos;
+					unify_raise acc_expr.etype t acc_expr.epos;
 					acc_expr
 					acc_expr
 				with Error (Unify(l),p) ->
 				with Error (Unify(l),p) ->
 					try_last_resort (fun () ->
 					try_last_resort (fun () ->

+ 2 - 2
src/typing/generic.ml

@@ -305,7 +305,7 @@ let rec build_generic ctx c p tl =
 				let t = spawn_monomorph ctx p in
 				let t = spawn_monomorph ctx p in
 				r := lazy_processing (fun() -> t);
 				r := lazy_processing (fun() -> t);
 				let t0 = f() in
 				let t0 = f() in
-				unify_raise ctx t0 t p;
+				unify_raise t0 t p;
 				link_dynamic t0 t;
 				link_dynamic t0 t;
 				t
 				t
 			) "build_generic" in
 			) "build_generic" in
@@ -379,7 +379,7 @@ let type_generic_function ctx fa fcc with_type p =
 		let gctx = make_generic ctx cf.cf_params monos p in
 		let gctx = make_generic ctx cf.cf_params monos p in
 		let name = cf.cf_name ^ "_" ^ gctx.name in
 		let name = cf.cf_name ^ "_" ^ gctx.name in
 		let unify_existing_field tcf pcf = try
 		let unify_existing_field tcf pcf = try
-			unify_raise ctx tcf fcc.fc_type p
+			unify_raise tcf fcc.fc_type p
 		with Error(Unify _,_) as err ->
 		with Error(Unify _,_) as err ->
 			display_error ctx ("Cannot create field " ^ name ^ " due to type mismatch") p;
 			display_error ctx ("Cannot create field " ^ name ^ " due to type mismatch") p;
 			display_error ctx (compl_msg "Conflicting field was defined here") pcf;
 			display_error ctx (compl_msg "Conflicting field was defined here") pcf;

+ 1 - 1
src/typing/instanceBuilder.ml

@@ -77,7 +77,7 @@ let build_instance ctx mtype p =
 				let t = spawn_monomorph ctx p in
 				let t = spawn_monomorph ctx p in
 				r := lazy_processing (fun() -> t);
 				r := lazy_processing (fun() -> t);
 				let tf = (f()) in
 				let tf = (f()) in
-				unify_raise ctx tf t p;
+				unify_raise tf t p;
 				link_dynamic t tf;
 				link_dynamic t tf;
 				(match tf with
 				(match tf with
 					| TInst (c, _) -> ignore(c.cl_build())
 					| TInst (c, _) -> ignore(c.cl_build())

+ 3 - 3
src/typing/macroContext.ml

@@ -651,13 +651,13 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 		let cttype = mk_type_path (["haxe";"macro"],"Type") in
 		let cttype = mk_type_path (["haxe";"macro"],"Type") in
 		let ttype = Typeload.load_instance mctx (cttype,p) false in
 		let ttype = Typeload.load_instance mctx (cttype,p) false in
 		try
 		try
-			unify_raise mctx mret ttype mpos;
+			unify_raise mret ttype mpos;
 			(* TODO: enable this again in the future *)
 			(* TODO: enable this again in the future *)
 			(* warning ctx WDeprecated "Returning Type from @:genericBuild macros is deprecated, consider returning ComplexType instead" p; *)
 			(* warning ctx WDeprecated "Returning Type from @:genericBuild macros is deprecated, consider returning ComplexType instead" p; *)
 		with Error (Unify _,_) ->
 		with Error (Unify _,_) ->
 			let cttype = mk_type_path ~sub:"ComplexType" (["haxe";"macro"],"Expr") in
 			let cttype = mk_type_path ~sub:"ComplexType" (["haxe";"macro"],"Expr") in
 			let ttype = Typeload.load_instance mctx (cttype,p) false in
 			let ttype = Typeload.load_instance mctx (cttype,p) false in
-			unify_raise mctx mret ttype mpos;
+			unify_raise mret ttype mpos;
 	);
 	);
 	(*
 	(*
 		if the function's last argument is of Array<Expr>, split the argument list and use [] for unify_call_args
 		if the function's last argument is of Array<Expr>, split the argument list and use [] for unify_call_args
@@ -688,7 +688,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 			force default parameter types to haxe.macro.Expr, and if success allow to pass any value type since it will be encoded
 			force default parameter types to haxe.macro.Expr, and if success allow to pass any value type since it will be encoded
 		*)
 		*)
 		let eargs = List.map (fun (n,o,t) ->
 		let eargs = List.map (fun (n,o,t) ->
-			try unify_raise mctx t expr p; (n, o, t_dynamic), MAExpr
+			try unify_raise t expr p; (n, o, t_dynamic), MAExpr
 			with Error (Unify _,_) -> match follow t with
 			with Error (Unify _,_) -> match follow t with
 				| TFun _ ->
 				| TFun _ ->
 					(n,o,t), MAFunction
 					(n,o,t), MAFunction

+ 1 - 1
src/typing/operators.ml

@@ -405,7 +405,7 @@ let find_abstract_binop_overload ctx op e1 e2 a c tl left is_assign_op with_type
 				let result = make_binop ctx op {e1 with etype = Abstract.follow_with_abstracts e1.etype} {e1 with etype = Abstract.follow_with_abstracts e2.etype} is_assign_op with_type p in
 				let result = make_binop ctx op {e1 with etype = Abstract.follow_with_abstracts e1.etype} {e1 with etype = Abstract.follow_with_abstracts e2.etype} is_assign_op with_type p in
 				let t_expected = BinopResult.get_type result in
 				let t_expected = BinopResult.get_type result in
 				begin try
 				begin try
-					unify_raise ctx tret t_expected p
+					unify_raise tret t_expected p
 				with Error (Unify _,_) ->
 				with Error (Unify _,_) ->
 					match follow tret with
 					match follow tret with
 						| TAbstract(a,tl) when type_iseq (Abstract.get_underlying_type a tl) t_expected ->
 						| TAbstract(a,tl) when type_iseq (Abstract.get_underlying_type a tl) t_expected ->

+ 2 - 2
src/typing/typeload.ml

@@ -285,7 +285,7 @@ let check_param_constraints ctx t map c p =
 		List.iter (fun ti ->
 		List.iter (fun ti ->
 			let ti = map ti in
 			let ti = map ti in
 			try
 			try
-				unify_raise ctx t ti p
+				unify_raise t ti p
 			with Error(Unify l,p) ->
 			with Error(Unify l,p) ->
 				let fail() =
 				let fail() =
 					if not ctx.untyped then display_error ctx (error_msg (Unify (Constraint_failure (s_type_path c.cl_path) :: l))) p;
 					if not ctx.untyped then display_error ctx (error_msg (Unify (Constraint_failure (s_type_path c.cl_path) :: l))) p;
@@ -293,7 +293,7 @@ let check_param_constraints ctx t map c p =
 				match follow t with
 				match follow t with
 				| TInst({cl_kind = KExpr e},_) ->
 				| TInst({cl_kind = KExpr e},_) ->
 					let e = type_expr {ctx with locals = PMap.empty} e (WithType.with_type ti) in
 					let e = type_expr {ctx with locals = PMap.empty} e (WithType.with_type ti) in
-					begin try unify_raise ctx e.etype ti p
+					begin try unify_raise e.etype ti p
 					with Error (Unify _,_) -> fail() end
 					with Error (Unify _,_) -> fail() end
 				| _ ->
 				| _ ->
 					fail()
 					fail()

+ 2 - 2
src/typing/typeloadFields.ml

@@ -1070,7 +1070,7 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 					(* TODO: this doesn't seem quite right... *)
 					(* TODO: this doesn't seem quite right... *)
 					if not (has_class_field_flag cf CfImpl) then add_class_field_flag cf CfImpl;
 					if not (has_class_field_flag cf CfImpl) then add_class_field_flag cf CfImpl;
 					let resolve_m args =
 					let resolve_m args =
-						(try unify_raise ctx t (tfun (tthis :: args) m) cf.cf_pos with Error (Unify l,p) -> typing_error (error_msg (Unify l)) p);
+						(try unify_raise t (tfun (tthis :: args) m) cf.cf_pos with Error (Unify l,p) -> typing_error (error_msg (Unify l)) p);
 						match follow m with
 						match follow m with
 							| TMono _ when (match t with TFun(_,r) -> r == t_dynamic | _ -> false) -> t_dynamic
 							| TMono _ when (match t with TFun(_,r) -> r == t_dynamic | _ -> false) -> t_dynamic
 							| m -> m
 							| m -> m
@@ -1468,7 +1468,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
 							display_error ctx (f2.cf_name ^ ": Macro methods cannot be used as property accessor") p;
 							display_error ctx (f2.cf_name ^ ": Macro methods cannot be used as property accessor") p;
 							display_error ctx (compl_msg (f2.cf_name ^ ": Accessor method is here")) f2.cf_pos;
 							display_error ctx (compl_msg (f2.cf_name ^ ": Accessor method is here")) f2.cf_pos;
 						| _ -> ());
 						| _ -> ());
-					unify_raise ctx t2 t f2.cf_pos;
+					unify_raise t2 t f2.cf_pos;
 					if (fctx.is_abstract_member && not (has_class_field_flag f2 CfImpl)) || (has_class_field_flag f2 CfImpl && not (fctx.is_abstract_member)) then
 					if (fctx.is_abstract_member && not (has_class_field_flag f2 CfImpl)) || (has_class_field_flag f2 CfImpl && not (fctx.is_abstract_member)) then
 						display_error ctx "Mixing abstract implementation and static properties/accessors is not allowed" f2.cf_pos;
 						display_error ctx "Mixing abstract implementation and static properties/accessors is not allowed" f2.cf_pos;
 				with Error (Unify l,p) ->
 				with Error (Unify l,p) ->