Sfoglia il codice sorgente

[typer] print module signature on redefined errors

Simon Krajewski 2 anni fa
parent
commit
6de559aaf0

+ 7 - 3
src/typing/typeloadCheck.ml

@@ -317,9 +317,13 @@ let check_global_metadata ctx meta f_add mpath tpath so =
 let check_module_types ctx m p t =
 let check_module_types ctx m p t =
 	let t = t_infos t in
 	let t = t_infos t in
 	try
 	try
-		let m2 = ctx.com.type_to_module#find t.mt_path in
-		if m.m_path <> m2 && String.lowercase (s_type_path m2) = String.lowercase (s_type_path m.m_path) then typing_error ("Module " ^ s_type_path m2 ^ " is loaded with a different case than " ^ s_type_path m.m_path) p;
-		typing_error ("Type name " ^ s_type_path t.mt_path ^ " is redefined from module " ^ s_type_path m2) p
+		let path2 = ctx.com.type_to_module#find t.mt_path in
+		if m.m_path <> path2 && String.lowercase (s_type_path path2) = String.lowercase (s_type_path m.m_path) then typing_error ("Module " ^ s_type_path path2 ^ " is loaded with a different case than " ^ s_type_path m.m_path) p;
+		let m2 = ctx.com.module_lut#find path2 in
+		let hex1 = Digest.to_hex m.m_extra.m_sign in
+		let hex2 = Digest.to_hex m2.m_extra.m_sign in
+		let s = if hex1 = hex2 then hex1 else Printf.sprintf "was %s, is %s" hex2 hex1 in
+		typing_error (Printf.sprintf "Type name %s is redefined from module %s (%s)" (s_type_path t.mt_path)  (s_type_path path2) s) p
 	with
 	with
 		Not_found ->
 		Not_found ->
 			ctx.com.type_to_module#add t.mt_path m.m_path
 			ctx.com.type_to_module#add t.mt_path m.m_path

+ 2 - 2
src/typing/typeloadModule.ml

@@ -747,11 +747,11 @@ let create_typer_context_for_module ctx m = {
 (*
 (*
 	Creates a module context for [m] and types [tdecls] using it.
 	Creates a module context for [m] and types [tdecls] using it.
 *)
 *)
-let type_types_into_module ?(check=true) ctx m tdecls p =
+let type_types_into_module ctx m tdecls p =
 	let ctx = create_typer_context_for_module ctx m in
 	let ctx = create_typer_context_for_module ctx m in
 	let decls,tdecls = ModuleLevel.create_module_types ctx m tdecls p in
 	let decls,tdecls = ModuleLevel.create_module_types ctx m tdecls p in
 	let types = List.map fst decls in
 	let types = List.map fst decls in
-	if check then List.iter (TypeloadCheck.check_module_types ctx m p) types;
+	List.iter (TypeloadCheck.check_module_types ctx m p) types;
 	m.m_types <- m.m_types @ types;
 	m.m_types <- m.m_types @ types;
 	(* define the per-module context for the next pass *)
 	(* define the per-module context for the next pass *)
 	if ctx.g.std != null_module then begin
 	if ctx.g.std != null_module then begin

+ 0 - 1
tests/server/src/cases/ServerTests.hx

@@ -86,7 +86,6 @@ class ServerTests extends TestCase {
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("BuildMacro.hx")});
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("BuildMacro.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		// assertNotCacheModified("BuildMacro");
 		// assertNotCacheModified("BuildMacro");
-		trace(lastResult);
 		assertSkipping("BuiltClass", DependencyDirty("BuildMacro - Tainted server/invalidate"));
 		assertSkipping("BuiltClass", DependencyDirty("BuildMacro - Tainted server/invalidate"));
 		assertSkipping("BuildMacro", Tainted("server/invalidate"));
 		assertSkipping("BuildMacro", Tainted("server/invalidate"));
 	}
 	}