Browse Source

php : added error message when using 2 fields with different cases in the same class/enum

Franco Ponticelli 15 years ago
parent
commit
d806db43b0
2 changed files with 22 additions and 0 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 21 0
      genphp.ml

+ 1 - 0
doc/CHANGES.txt

@@ -38,6 +38,7 @@
 	all : only allow "using" on Dynamic if first parameter is Dynamic
 	php : haxe.Http now supports Https connections when OpenSSL extension is enabled (issue 143)
 	php : fixed enum constructors sequence (issue 142)
+	php : added error message when using 2 fields with different cases in the same class/enum
 	
 2010-01-09: 2.05
 	js : added js.Scroll

+ 21 - 0
genphp.ml

@@ -1922,6 +1922,27 @@ let generate_enum ctx e =
 let generate com =
 	let all_dynamic_methods = ref [] in
 	let extern_classes_with_init = ref [] in
+	(* check for fields with the same name but different casing *)
+	List.iter (fun t ->
+		(match t with
+		| TClassDecl c ->
+			let lc_names = ref [] in
+			List.iter(fun f -> (
+				if List.exists (fun n -> n = String.lowercase f.cf_name) !lc_names then
+					unsupported ("'" ^ f.cf_name ^ "' already exists with different case") c.cl_pos
+				else
+					!lc_names <- (String.lowercase f.cf_name) :: !lc_names
+			)) (c.cl_ordered_fields @ c.cl_ordered_statics)
+		| TEnumDecl e ->
+			let e_names = ref [] in
+			List.iter(fun en -> (
+				if List.exists (fun n -> n = String.lowercase en) !e_names then
+					unsupported ("'" ^ en ^ "' constructor exists with different case") e.e_pos
+				else
+					!e_names <- (String.lowercase en) :: !e_names
+			)) (e.e_names)
+		| _ -> ())
+	) com.types;
 	List.iter (fun t ->
 		(match t with
 		| TClassDecl c ->