Quellcode durchsuchen

Use more specific invalidation reasons

Rudy Ges vor 7 Monaten
Ursprung
Commit
664a10b19f

+ 3 - 0
src/core/tPrinting.ml

@@ -637,8 +637,11 @@ module Printer = struct
 
 	let s_module_tainting_reason = function
 		| CheckDisplayFile -> "check_display_file"
+		| DefineType -> "define_type"
+		| DefineModule -> "define_module"
 		| ServerInvalidate -> "server/invalidate"
 		| ServerInvalidateFiles -> "server_invalidate_files"
+		| ServerInvalidateModule -> "server_invalidate_module"
 
 	let s_module_skip_reason reason =
 		let rec loop stack = function

+ 3 - 0
src/core/tType.ml

@@ -32,8 +32,11 @@ type module_check_policy =
 
 type module_tainting_reason =
 	| CheckDisplayFile
+	| DefineType
+	| DefineModule
 	| ServerInvalidate
 	| ServerInvalidateFiles
+	| ServerInvalidateModule
 
 type module_skip_reason =
 	| DependencyDirty of path * module_skip_reason

+ 1 - 1
src/macro/macroApi.ml

@@ -2332,7 +2332,7 @@ let macro_api ccom get_api =
 				let pos = get_api_call_pos() in
 				compiler_error (Error.make_error (Custom msg) pos)
 			with Not_found ->
-				com.cs#taint_module mpath ServerInvalidate);
+				com.cs#taint_module mpath ServerInvalidateModule);
 			vnull
 		);
 		"server_invalidate_files", vfun1 (fun a ->

+ 2 - 2
src/typing/macroContext.ml

@@ -471,7 +471,7 @@ let make_macro_api ctx mctx p =
 						make_error ~depth:1 (Custom "Previously defined here") pos
 					] (Custom (Printf.sprintf "Cannot redefine module %s" (s_type_path mpath))) p);
 				with Not_found ->
-					ctx.com.cs#taint_module mpath ServerInvalidate;
+					ctx.com.cs#taint_module mpath DefineType;
 					let mdep = Option.map_default (fun s -> TypeloadModule.load_module ~origin:MDepFromMacro ctx (parse_path s) pos) ctx.m.curmod mdep in
 					let mnew = TypeloadModule.type_module ctx.com ctx.g ~dont_check_path:(has_native_meta) mpath (ctx.com.file_keys#generate_virtual mpath ctx.com.compilation_step) [tdef,pos] pos in
 					mnew.m_extra.m_kind <- if is_macro then MMacro else MFake;
@@ -510,7 +510,7 @@ let make_macro_api ctx mctx p =
 				end else
 					ignore(TypeloadModule.type_types_into_module ctx.com ctx.g ctx.m.curmod types pos)
 			with Not_found ->
-				ctx.com.cs#taint_module mpath ServerInvalidate;
+				ctx.com.cs#taint_module mpath DefineModule;
 				let mnew = TypeloadModule.type_module ctx.com ctx.g mpath (ctx.com.file_keys#generate_virtual mpath ctx.com.compilation_step) types pos in
 				mnew.m_extra.m_kind <- MFake;
 				add_dependency mnew ctx.m.curmod MDepFromMacro;

+ 2 - 4
tests/server/src/cases/issues/Issue12001.hx

@@ -24,8 +24,7 @@ class Issue12001 extends TestCase {
 
 		runHaxe(args);
 		assertSuccess();
-		// TODO: change invalidation reason
-		assertSkipping("Main", DependencyDirty("Foo - Tainted server/invalidate"));
+		assertSkipping("Main", DependencyDirty("Foo - Tainted define_type"));
 	}
 
 	function testDefineModule(_) {
@@ -49,8 +48,7 @@ class Issue12001 extends TestCase {
 
 		runHaxe(args);
 		assertSuccess();
-		// TODO: change invalidation reason
-		assertSkipping("Main", DependencyDirty("Bar - Tainted server/invalidate"));
+		assertSkipping("Main", DependencyDirty("Bar - Tainted define_module"));
 	}
 
 	@:async