Jelajahi Sumber

restricts WithTypeError to the currently typed expression (close #5837)

Nicolas Cannasse 8 tahun lalu
induk
melakukan
ba756e9283
1 mengubah file dengan 11 tambahan dan 1 penghapusan
  1. 11 1
      src/typing/typer.ml

+ 11 - 1
src/typing/typer.ml

@@ -543,11 +543,21 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 		default_value name t
 	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 contains_pos e p =
+		let rec loop e =
+			if snd e = p then raise Exit
+			Ast.iter_expr loop e
+		in
+		try
+			loop e; false
+		with Exit ->
+			true
+	in
 	let type_against t e =
 		try
 			let e = type_expr ctx e (WithType t) in
 			AbstractCast.cast_or_unify_raise ctx t e e.epos
-		with Error(l,p) when (match l with Call_error _ | Module_not_found _ -> false | _ -> true) ->
+		with Error(l,p) when (match l with Call_error _ | Module_not_found _ -> false | _ -> contains_pos e p) ->
 			raise (WithTypeError (l,p))
 	in
 	let rec loop el args = match el,args with