Browse Source

[display] remove pos argument from handle_display function (see https://github.com/HaxeFoundation/haxe/commit/f6b9c0d86bf200f467fb03c8a6291af3947f3451#commitcomment-17202700)

Dan Korostelev 9 năm trước cách đây
mục cha
commit
e9b91957c8
2 tập tin đã thay đổi với 9 bổ sung8 xóa
  1. 1 1
      src/typing/matcher.ml
  2. 8 7
      src/typing/typer.ml

+ 1 - 1
src/typing/matcher.ml

@@ -404,7 +404,7 @@ module Pattern = struct
 				PatExtractor(v,e1,pat)
 			| EDisplay(e,call) ->
 				let pat = loop e in
-				let _ = Typer.handle_display ctx e call (WithType t) p in
+				let _ = Typer.handle_display ctx e call (WithType t) in
 				pat
 			| _ ->
 				fail()

+ 8 - 7
src/typing/typer.ml

@@ -3544,7 +3544,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 						mk (TConst TNull) t_dynamic p
 				)
 			) in
-			if display then ignore(handle_display ctx (EConst(Ident i.v_name),i.v_pos) false (WithType i.v_type) i.v_pos);
+			if display then ignore(handle_display ctx (EConst(Ident i.v_name),i.v_pos) false (WithType i.v_type));
 			let e2 = type_expr ctx e2 NoValue in
 			(try Optimizer.optimize_for_loop_iterator ctx i e1 e2 p with Exit -> mk (TFor (i,e1,e2)) ctx.t.tvoid p)
 		in
@@ -3684,7 +3684,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 		let texpr = loop t in
 		mk (TCast (type_expr ctx e Value,Some texpr)) t p
 	| EDisplay (e,iscall) ->
-		handle_display ctx e iscall with_type p
+		handle_display ctx e iscall with_type
 	| EDisplayNew (t,_) ->
 		let t = Typeload.load_instance ctx (t,p) true in
 		(match follow t with
@@ -3740,7 +3740,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 		ctx.meta <- old;
 		e
 
-and handle_display ctx e_ast iscall with_type p =
+and handle_display ctx e_ast iscall with_type =
 	let old = ctx.in_display,ctx.in_call_args in
 	ctx.in_display <- true;
 	ctx.in_call_args <- false;
@@ -3753,8 +3753,8 @@ and handle_display ctx e_ast iscall with_type p =
 		) tl in
 		tl
 	in
-	let e,p = try
-		type_expr ctx e_ast with_type,p
+	let e = try
+		type_expr ctx e_ast with_type
 	with Error (Unknown_ident n,_) when not iscall ->
 		raise (Parser.TypePath ([n],None,false))
 	| Error (Unknown_ident "trace",_) ->
@@ -3765,12 +3765,13 @@ and handle_display ctx e_ast iscall with_type p =
 		with Not_found ->
 			raise err
 		end
-	| Display.DisplaySubExpression ((_,p) as e) ->
+	| Display.DisplaySubExpression e ->
 		ctx.in_display <- false;
 		let e = type_expr ctx e Value in
 		ctx.in_display <- true;
-		e,p
+		e
 	in
+	let p = e.epos in
 	let e = match with_type with
 		| WithType t -> (try Codegen.AbstractCast.cast_or_unify_raise ctx t e e.epos with Error (Unify l,p) -> e)
 		| _ -> e