Browse Source

[cs] Check `params` array by length. Closes #4407

Cauê Waneck 10 years ago
parent
commit
3c9fc5d068
2 changed files with 17 additions and 1 deletions
  1. 1 1
      std/cs/_std/Type.hx
  2. 16 0
      tests/unit/src/unit/issues/Issue4407.hx

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

@@ -196,7 +196,7 @@ using StringTools;
 
 	public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T
 	{
-		if (params == null || params[0] == null)
+		if (params == null || params.length == 0)
 		{
 			var ret = cs.internal.Runtime.slowGetField(e, constr, true);
 			if (Reflect.isFunction(ret))

+ 16 - 0
tests/unit/src/unit/issues/Issue4407.hx

@@ -0,0 +1,16 @@
+package unit.issues;
+
+class Issue4407 extends Test
+{
+	public function test()
+	{
+		// please don't optimize this too much
+		var ex:Dynamic = Example;
+		t( Type.enumEq( Type.createEnum(ex, "NullParam", untyped [null, "123"]), Example.NullParam(null,"123")) );
+	}
+}
+
+private enum Example
+{
+    NullParam(first:Null<Int>, second:String);
+}