From 5c1a3defc6ba20fd833c99012c01195f39e515e6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 31 May 2005 01:16:01 +0000 Subject: r7124: fixed a bug in array construction (see ECMA standard section 15.4.2.2) (This used to be commit f9f1d85e651afca7a65804b3124daa11208965e8) --- source4/lib/ejs/ejsProcs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/ejs/ejsProcs.c b/source4/lib/ejs/ejsProcs.c index 39df18ef94..b15985c8cf 100644 --- a/source4/lib/ejs/ejsProcs.c +++ b/source4/lib/ejs/ejsProcs.c @@ -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)); -- cgit