فهرست منبع

bring back Failure catching

I have to review this though...
Simon Krajewski 5 ماه پیش
والد
کامیت
4f88ce8365
2فایلهای تغییر یافته به همراه13 افزوده شده و 11 حذف شده
  1. 10 7
      src/context/safeCom.ml
  2. 3 4
      tests/display/src/cases/Issue11211.hx

+ 10 - 7
src/context/safeCom.ml

@@ -47,13 +47,16 @@ let add_warning com w msg p =
 
 
 let run_expression_filters_safe (com : t) detail_times filters t =
 let run_expression_filters_safe (com : t) detail_times filters t =
 	let run com identifier e =
 	let run com identifier e =
-		List.fold_left (fun e (filter_name,f) ->
-			try
-				FilterContext.with_timer detail_times filter_name identifier (fun () -> f com e)
-			with exc ->
-				add_exn com exc;
-				e
-		) e filters
+		try
+			List.fold_left (fun e (filter_name,f) ->
+				try
+					FilterContext.with_timer detail_times filter_name identifier (fun () -> f com e)
+				with Failure msg ->
+					Error.raise_typing_error msg e.epos
+			) e filters
+		with exc ->
+			add_exn com exc;
+			e
 	in
 	in
 	match t with
 	match t with
 	| TClassDecl c when FilterContext.is_removable_class c -> ()
 	| TClassDecl c when FilterContext.is_removable_class c -> ()

+ 3 - 4
tests/display/src/cases/Issue11211.hx

@@ -31,7 +31,7 @@ class Issue11211 extends DisplayTestCase {
 		@:build(Issue11211.SafeAst.build())
 		@:build(Issue11211.SafeAst.build())
 		class Main {
 		class Main {
 			static function main() {
 			static function main() {
-				var errRa{-1-}nge:Null<Int> = 0;
+				var errRa{-1-}nge = 0;
 				{-4-}final pre{-2-}vId = trace("arg");{-5-}
 				{-4-}final pre{-2-}vId = trace("arg");{-5-}
 				if (errRange != null) {
 				if (errRange != null) {
 					final has{-3-}Comma = false;
 					final has{-3-}Comma = false;
@@ -41,10 +41,9 @@ class Issue11211 extends DisplayTestCase {
 		#end
 		#end
 	**/
 	**/
 	function test() {
 	function test() {
-		eq("Null<Int>", type(pos(1)));
+		eq("Int", type(pos(1)));
 		eq("Void", type(pos(2)));
 		eq("Void", type(pos(2)));
 		eq("Bool", type(pos(3)));
 		eq("Bool", type(pos(3)));
-		var d = diagnostics();
 		arrayEq([
 		arrayEq([
 			{
 			{
 				kind: DKCompilerError,
 				kind: DKCompilerError,
@@ -54,6 +53,6 @@ class Issue11211 extends DisplayTestCase {
 				relatedInformation: [],
 				relatedInformation: [],
 				args: "Variables of type Void are not allowed"
 				args: "Variables of type Void are not allowed"
 			},
 			},
-		], d);
+		], diagnostics());
 	}
 	}
 }
 }