ソースを参照

Disallow importing types with lowercase aliases (see #3457)

Dan Korostelev 10 年 前
コミット
ba96ca83da

+ 1 - 0
tests/misc/projects/Issue3457/A.hx

@@ -0,0 +1 @@
+class A {}

+ 1 - 0
tests/misc/projects/Issue3457/Main.hx

@@ -0,0 +1 @@
+import A in a;

+ 1 - 0
tests/misc/projects/Issue3457/compile-fail.hxml

@@ -0,0 +1 @@
+Main

+ 1 - 0
tests/misc/projects/Issue3457/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:1: characters 7-8 : Type aliases must start with an uppercase letter

+ 2 - 0
typeload.ml

@@ -2383,6 +2383,8 @@ let rec init_module_type ctx context_init do_init (decl,p) =
 				t
 			in
 			let rebind t name =
+				if not (name.[0] >= 'A' && name.[0] <= 'Z') then
+					error "Type aliases must start with an uppercase letter" p;
 				let _, _, f = ctx.g.do_build_instance ctx t p in
 				(* create a temp private typedef, does not register it in module *)
 				TTypeDecl {