Browse Source

prevent extension of basic classes

Nicolas Cannasse 17 years ago
parent
commit
3d05e22634
2 changed files with 7 additions and 1 deletions
  1. 2 1
      doc/CHANGES.txt
  2. 5 0
      typeload.ml

+ 2 - 1
doc/CHANGES.txt

@@ -1,4 +1,4 @@
-xxxx-xx-xx: 2.02 CVS
+2008-??-??: 2.02 CVS
 	Std.is(MyInterface, Class) now returns true (haXe/PHP)
 	Std.is(MyInterface, Class) now returns true (haXe/PHP)
 	php arrays are wrapped into _hx_array instances, fixes issues with references (array cast, access out of bounds ...)
 	php arrays are wrapped into _hx_array instances, fixes issues with references (array cast, access out of bounds ...)
 	removed untested php classes (php.DBase, php.IniHash)
 	removed untested php classes (php.DBase, php.IniHash)
@@ -6,6 +6,7 @@ xxxx-xx-xx: 2.02 CVS
 	flash.Lib.getTimer() now returns Int and is inlined
 	flash.Lib.getTimer() now returns Int and is inlined
 	fixed php.FileSystem.stat
 	fixed php.FileSystem.stat
 	added memory related functions to php.Sys
 	added memory related functions to php.Sys
+	added error when trying to extend Array, String, Date and Xml
 
 
 2008-10-04: 2.01
 2008-10-04: 2.01
 	fixed php.Sys
 	fixed php.Sys

+ 5 - 0
typeload.ml

@@ -409,6 +409,11 @@ let set_heritance ctx c herits p =
 			if c.cl_super <> None then error "Cannot extend several classes" p;
 			if c.cl_super <> None then error "Cannot extend several classes" p;
 			let t = load_normal_type ctx t p false in
 			let t = load_normal_type ctx t p false in
 			(match follow t with
 			(match follow t with
+			| TInst ({ cl_path = [],"Array" },_)
+			| TInst ({ cl_path = [],"String" },_)
+			| TInst ({ cl_path = [],"Date" },_)
+			| TInst ({ cl_path = [],"Xml" },_) ->
+				error "Cannot extend basic class" p;
 			| TInst (cl,params) ->
 			| TInst (cl,params) ->
 				if is_parent c cl then error "Recursive class" p;
 				if is_parent c cl then error "Recursive class" p;
 				if c.cl_interface then error "Cannot extend an interface" p;
 				if c.cl_interface then error "Cannot extend an interface" p;