Skip to content

Commit

Permalink
[cs] Check params array by length. Closes HaxeFoundation#4407
Browse files Browse the repository at this point in the history
  • Loading branch information
waneck committed Jul 14, 2015
1 parent 5c51ed0 commit 3c9fc5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion std/cs/_std/Type.hx
Expand Up @@ -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))
Expand Down
16 changes: 16 additions & 0 deletions 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);
}

0 comments on commit 3c9fc5d

Please sign in to comment.