Преглед на файлове

[CS] Avoid CA2200 warning when rethrowing (#9999)

Rudy Ges преди 4 години
родител
ревизия
f59be493ff
променени са 3 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 2 1
      src/core/tType.ml
  2. 2 1
      src/filters/exceptions.ml
  3. 2 0
      src/generators/gencs.ml

+ 2 - 1
src/core/tType.ml

@@ -400,4 +400,5 @@ type flag_tclass_field =
 type flag_tvar =
 	| VCaptured
 	| VFinal
-	| VUsed (* used by the analyzer *)
+	| VUsed (* used by the analyzer *)
+	| VCaught

+ 2 - 1
src/filters/exceptions.ml

@@ -275,6 +275,7 @@ let catch_native ctx catches t p =
 		(* Everything else falls into `if(Std.is(e, ExceptionType)`-fest *)
 		| rest ->
 			let catch_var = alloc_var VGenerated "`" ctx.wildcard_catch_type null_pos in
+			add_var_flag catch_var VCaught;
 			let catch_local = mk (TLocal catch_var) catch_var.v_type null_pos in
 			let body =
 				let catch = new catch ctx catch_local p in
@@ -570,4 +571,4 @@ let patch_constructors tctx =
 				)
 			| _ -> ()
 		)
-	| _ -> (fun _ -> ())
+	| _ -> (fun _ -> ())

+ 2 - 0
src/generators/gencs.ml

@@ -1762,6 +1762,8 @@ let generate con =
 					| TContinue -> write w "continue"
 					| TThrow { eexpr = TIdent "__rethrow__" } ->
 						write w "throw"
+					| TThrow { eexpr = TLocal(v) } when (has_var_flag v VCaught) ->
+						write w "throw";
 					| TThrow e ->
 						write w "throw ";
 						expr_s w e