Browse Source

Deal with externs

Jens Fischer 6 years ago
parent
commit
62440d089c

+ 3 - 3
src/typing/typeloadModule.ml

@@ -187,7 +187,6 @@ end
 	Build module structure : should be atomic - no type loading is possible
 	Build module structure : should be atomic - no type loading is possible
 *)
 *)
 let module_pass_1 ctx m tdecls loadp =
 let module_pass_1 ctx m tdecls loadp =
-	Typecore.check_module_path ctx m.m_path loadp;
 	let com = ctx.com in
 	let com = ctx.com in
 	let decls = ref [] in
 	let decls = ref [] in
 	let make_path name priv =
 	let make_path name priv =
@@ -208,7 +207,6 @@ let module_pass_1 ctx m tdecls loadp =
 			| Some _ -> error "import and using may not appear after a type declaration" p)
 			| Some _ -> error "import and using may not appear after a type declaration" p)
 		| EClass d ->
 		| EClass d ->
 			let name = fst d.d_name in
 			let name = fst d.d_name in
-			check_type_name name;
 			pt := Some p;
 			pt := Some p;
 			let priv = List.mem HPrivate d.d_flags in
 			let priv = List.mem HPrivate d.d_flags in
 			let path = make_path name priv in
 			let path = make_path name priv in
@@ -225,11 +223,11 @@ let module_pass_1 ctx m tdecls loadp =
 				| HFinal -> c.cl_final <- true
 				| HFinal -> c.cl_final <- true
 				| _ -> ()
 				| _ -> ()
 			) d.d_flags;
 			) d.d_flags;
+			if not c.cl_extern then check_type_name name;
 			decls := (TClassDecl c, decl) :: !decls;
 			decls := (TClassDecl c, decl) :: !decls;
 			acc
 			acc
 		| EEnum d ->
 		| EEnum d ->
 			let name = fst d.d_name in
 			let name = fst d.d_name in
-			check_type_name name;
 			pt := Some p;
 			pt := Some p;
 			let priv = List.mem EPrivate d.d_flags in
 			let priv = List.mem EPrivate d.d_flags in
 			let path = make_path name priv in
 			let path = make_path name priv in
@@ -249,6 +247,7 @@ let module_pass_1 ctx m tdecls loadp =
 				e_names = [];
 				e_names = [];
 				e_type = enum_module_type m path p;
 				e_type = enum_module_type m path p;
 			} in
 			} in
+			if not e.e_extern then check_type_name name;
 			decls := (TEnumDecl e, decl) :: !decls;
 			decls := (TEnumDecl e, decl) :: !decls;
 			acc
 			acc
 		| ETypedef d ->
 		| ETypedef d ->
@@ -942,6 +941,7 @@ let type_module ctx mpath file ?(is_extern=false) tdecls p =
 	let tdecls = handle_import_hx ctx m tdecls p in
 	let tdecls = handle_import_hx ctx m tdecls p in
 	let ctx = type_types_into_module ctx m tdecls p in
 	let ctx = type_types_into_module ctx m tdecls p in
 	if is_extern then m.m_extra.m_kind <- MExtern;
 	if is_extern then m.m_extra.m_kind <- MExtern;
+	if not is_extern then Typecore.check_module_path ctx m.m_path p;
 	begin if ctx.is_display_file then match ctx.com.display.dms_kind with
 	begin if ctx.is_display_file then match ctx.com.display.dms_kind with
 		| DMResolve s ->
 		| DMResolve s ->
 			DisplayPath.resolve_position_by_path ctx {tname = s; tpackage = []; tsub = None; tparams = []} p
 			DisplayPath.resolve_position_by_path ctx {tname = s; tpackage = []; tsub = None; tparams = []} p

+ 2 - 2
tests/misc/projects/issue5002/compile3-fail.hxml.stderr

@@ -2,5 +2,5 @@ Main3.hx:9: characters 17-18 : Module name should start with an uppercase letter
 Main3.hx:9: characters 17-18 : "0_class" is not a valid module name
 Main3.hx:9: characters 17-18 : "0_class" is not a valid module name
 Main3.hx:9: characters 17-18 : "0_enum" is not a valid module name
 Main3.hx:9: characters 17-18 : "0_enum" is not a valid module name
 Main3.hx:9: characters 17-18 : "0_struct" is not a valid module name
 Main3.hx:9: characters 17-18 : "0_struct" is not a valid module name
-Main3.hx:9: characters 17-18 : "0_abstract" is not a valid module name
-Main3.hx:9: characters 17-18 : "0_abstract_Impl_" is not a valid type name
+Main3.hx:9: characters 17-18 : "0_abstract_Impl_" is not a valid type name
+Main3.hx:9: characters 17-18 : "0_abstract" is not a valid module name