Skip to content

Commit 664a10b

Browse files
committed
Use more specific invalidation reasons
1 parent cd92af6 commit 664a10b

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

src/core/tPrinting.ml

+3
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,11 @@ module Printer = struct
637637

638638
let s_module_tainting_reason = function
639639
| CheckDisplayFile -> "check_display_file"
640+
| DefineType -> "define_type"
641+
| DefineModule -> "define_module"
640642
| ServerInvalidate -> "server/invalidate"
641643
| ServerInvalidateFiles -> "server_invalidate_files"
644+
| ServerInvalidateModule -> "server_invalidate_module"
642645

643646
let s_module_skip_reason reason =
644647
let rec loop stack = function

src/core/tType.ml

+3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ type module_check_policy =
3232

3333
type module_tainting_reason =
3434
| CheckDisplayFile
35+
| DefineType
36+
| DefineModule
3537
| ServerInvalidate
3638
| ServerInvalidateFiles
39+
| ServerInvalidateModule
3740

3841
type module_skip_reason =
3942
| DependencyDirty of path * module_skip_reason

src/macro/macroApi.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ let macro_api ccom get_api =
23322332
let pos = get_api_call_pos() in
23332333
compiler_error (Error.make_error (Custom msg) pos)
23342334
with Not_found ->
2335-
com.cs#taint_module mpath ServerInvalidate);
2335+
com.cs#taint_module mpath ServerInvalidateModule);
23362336
vnull
23372337
);
23382338
"server_invalidate_files", vfun1 (fun a ->

src/typing/macroContext.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ let make_macro_api ctx mctx p =
471471
make_error ~depth:1 (Custom "Previously defined here") pos
472472
] (Custom (Printf.sprintf "Cannot redefine module %s" (s_type_path mpath))) p);
473473
with Not_found ->
474-
ctx.com.cs#taint_module mpath ServerInvalidate;
474+
ctx.com.cs#taint_module mpath DefineType;
475475
let mdep = Option.map_default (fun s -> TypeloadModule.load_module ~origin:MDepFromMacro ctx (parse_path s) pos) ctx.m.curmod mdep in
476476
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
477477
mnew.m_extra.m_kind <- if is_macro then MMacro else MFake;
@@ -510,7 +510,7 @@ let make_macro_api ctx mctx p =
510510
end else
511511
ignore(TypeloadModule.type_types_into_module ctx.com ctx.g ctx.m.curmod types pos)
512512
with Not_found ->
513-
ctx.com.cs#taint_module mpath ServerInvalidate;
513+
ctx.com.cs#taint_module mpath DefineModule;
514514
let mnew = TypeloadModule.type_module ctx.com ctx.g mpath (ctx.com.file_keys#generate_virtual mpath ctx.com.compilation_step) types pos in
515515
mnew.m_extra.m_kind <- MFake;
516516
add_dependency mnew ctx.m.curmod MDepFromMacro;

tests/server/src/cases/issues/Issue12001.hx

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class Issue12001 extends TestCase {
2424

2525
runHaxe(args);
2626
assertSuccess();
27-
// TODO: change invalidation reason
28-
assertSkipping("Main", DependencyDirty("Foo - Tainted server/invalidate"));
27+
assertSkipping("Main", DependencyDirty("Foo - Tainted define_type"));
2928
}
3029

3130
function testDefineModule(_) {
@@ -49,8 +48,7 @@ class Issue12001 extends TestCase {
4948

5049
runHaxe(args);
5150
assertSuccess();
52-
// TODO: change invalidation reason
53-
assertSkipping("Main", DependencyDirty("Bar - Tainted server/invalidate"));
51+
assertSkipping("Main", DependencyDirty("Bar - Tainted define_module"));
5452
}
5553

5654
@:async

0 commit comments

Comments
 (0)