Browse Source

[js] always return the copied array in Type.allEnums (closes #7209)

Dan Korostelev 7 years ago
parent
commit
b391d44ec0
2 changed files with 20 additions and 1 deletions
  1. 1 1
      std/js/_std/Type.hx
  2. 19 0
      tests/unit/src/unit/issues/Issue7209.hx

+ 1 - 1
std/js/_std/Type.hx

@@ -285,7 +285,7 @@ enum ValueType {
 	}
 	}
 
 
 	public inline static function allEnums<T>( e : Enum<T> ) : Array<T> {
 	public inline static function allEnums<T>( e : Enum<T> ) : Array<T> {
-		return untyped __define_feature__("Type.allEnums", e.__empty_constructs__);
+		return untyped __define_feature__("Type.allEnums", e.__empty_constructs__.slice());
 	}
 	}
 
 
 }
 }

+ 19 - 0
tests/unit/src/unit/issues/Issue7209.hx

@@ -0,0 +1,19 @@
+package unit.issues;
+
+private enum E {
+	A;
+	B;
+	C(v:Int);
+}
+
+class Issue7209 extends unit.Test {
+	function test() {
+		var allEnums = Type.allEnums(E);
+		aeq(allEnums, [A,B]);
+
+		allEnums.remove(B);
+		aeq(allEnums, [A]);
+
+		aeq(Type.allEnums(E), [A,B]);
+	}
+}