r7124: fixed a bug in array construction (see ECMA standard section 15.4.2.2)
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 May 2005 01:16:01 +0000 (01:16 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:19 +0000 (13:17 -0500)
(This used to be commit f9f1d85e651afca7a65804b3124daa11208965e8)

source4/lib/ejs/ejsProcs.c

index 39df18ef9461d02554161b7c4b042c052a80d7c6..b15985c8cf78f9cbbc3a59c887f4a772e09fd41c 100644 (file)
@@ -171,7 +171,7 @@ static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv)
        mprAssert(obj);
 
 
-       if (argc == 1) {
+       if (argc == 1 && mprVarIsNumber(argv[0]->type)) {
                /*
                 *      x = new Array(size);
                 */
@@ -181,7 +181,7 @@ static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv)
                        mprItoa(i, idx, sizeof(idx));
                        mprCreateProperty(obj, idx, &undef);
                }
-       } else if (argc > 1) {
+       } else {
                /*
                 *      x = new Array(element0, element1, ..., elementN):
                 */
@@ -190,9 +190,6 @@ static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv)
                        mprItoa(i, idx, sizeof(idx));
                        mprCreateProperty(obj, idx, argv[i]);
                }
-
-       } else {
-               max = 0;
        }
 
        lp = mprCreatePropertyValue(obj, "length", mprCreateIntegerVar(max));