@@ -465,12 +465,13 @@ let make_macro_api ctx mctx p =
465
465
in
466
466
let add is_macro ctx =
467
467
try
468
- let m_extra = ! TypeloadCacheHook. find_module_extra_hook ctx.com mpath in
469
- let pos = { pfile = (Path.UniqueKey. lazy_path m_extra.m_file); pmin = 0 ; pmax = 0 } in
468
+ let m = ctx.com.module_lut#find mpath in
469
+ let pos = { pfile = (Path.UniqueKey. lazy_path m. m_extra.m_file); pmin = 0 ; pmax = 0 } in
470
470
raise_typing_error_ext (make_error ~sub: [
471
471
make_error ~depth: 1 (Custom " Previously defined here" ) pos
472
472
] (Custom (Printf. sprintf " Cannot redefine module %s" (s_type_path mpath))) p);
473
473
with Not_found ->
474
+ ctx.com.cs#taint_module mpath ServerInvalidate ;
474
475
let mdep = Option. map_default (fun s -> TypeloadModule. load_module ~origin: MDepFromMacro ctx (parse_path s) pos) ctx.m.curmod mdep in
475
476
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
476
477
mnew.m_extra.m_kind < - if is_macro then MMacro else MFake ;
@@ -500,17 +501,16 @@ let make_macro_api ctx mctx p =
500
501
let types = imports @ usings @ types in
501
502
let mpath = Ast. parse_path m in
502
503
begin try
503
- let m = try Some (ctx.com.module_lut#find mpath) with Not_found -> None in
504
- if Option. is_some m && Option. get m == ctx.m.curmod then
505
- ignore(TypeloadModule. type_types_into_module ctx.com ctx.g ctx.m.curmod types pos)
506
- else begin
507
- let m_extra = match m with Some m -> m.m_extra | None -> ! TypeloadCacheHook. find_module_extra_hook ctx.com mpath in
508
- let pos = { pfile = (Path.UniqueKey. lazy_path m_extra.m_file); pmin = 0 ; pmax = 0 } in
504
+ let m = ctx.com.module_lut#find mpath in
505
+ if m != ctx.m.curmod then begin
506
+ let pos = { pfile = (Path.UniqueKey. lazy_path m.m_extra.m_file); pmin = 0 ; pmax = 0 } in
509
507
raise_typing_error_ext (make_error ~sub: [
510
508
make_error ~depth: 1 (Custom " Previously defined here" ) pos
511
509
] (Custom (Printf. sprintf " Cannot redefine module %s" (s_type_path mpath))) p);
512
- end
510
+ end else
511
+ ignore(TypeloadModule. type_types_into_module ctx.com ctx.g ctx.m.curmod types pos)
513
512
with Not_found ->
513
+ ctx.com.cs#taint_module mpath ServerInvalidate ;
514
514
let mnew = TypeloadModule. type_module ctx.com ctx.g mpath (ctx.com.file_keys#generate_virtual mpath ctx.com.compilation_step) types pos in
515
515
mnew.m_extra.m_kind < - MFake ;
516
516
add_dependency mnew ctx.m.curmod MDepFromMacro ;
0 commit comments