Closed Bug 155285 Opened 22 years ago Closed 22 years ago

Array.join(undefined) should use ','

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
trivial

Tracking

()

VERIFIED FIXED

People

(Reporter: rogerl, Assigned: rogerl)

References

Details

(Keywords: js1.5)

Attachments

(1 file, 1 obsolete file)

Try:
>a = [1,2]
>a.join(undefined)
1undefined2

Should be:
1,2

(ECMA 15.4.4.5, step 3)
Test suite expects 'undefined':

    Testcase ecma/Array/15.4.4.3-1.js failed
    var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new
Boolean(true) ); TEST_ARRAY.join(void 0) = ,,true,false,123,[object Object],true
FAILED! expected:
undefinedundefinedtrueundefinedfalseundefined123undefined[object
Object]undefinedtrue
Comment on attachment 89953 [details] [diff] [review]
Test for undefined value in argv[0]

>-    if (argc == 0)
>+    if (argc == 0 || JSVAL_IS_VOID(argv[0]))

Shouldn't this just be 
  if (JSVAL_IS_VOID(argv[0]))
???

(Unspecified args with positions < function.length have value JSVAL_VOID in the
argv[] array, so that if argc is zero then argv[0] is JSVAL_VOID, since
Array.join.length is 1.)

--scole
I'll buy that. Thanks.
Attachment #89953 - Attachment is obsolete: true
Blocks: 149801
cc'ing reviewers; adding js1.5 keyword; adding as dependency to bug 149801 -
Keywords: js1.5
Comment on attachment 89973 [details] [diff] [review]
Removed argc test

sr=brendan@mozilla.org, and I say scole already did a bang-up r= job.  Roger,
can you get this into the trunk and mail drivers asking for branch approval? 
Thanks,

/be
Attachment #89973 - Flags: superreview+
Attachment #89973 - Flags: review+
Fix checked in to trunk. Mailing drivers (but I'm on vacation thru Friday so 
someone else will have to check it in if it gets approval).
Keywords: mozilla1.0.1
Comment on attachment 89973 [details] [diff] [review]
Removed argc test

a=chofmann for 1.0.1  add fixed1.0.1 keyword after checking in on the branch
Comment on attachment 89973 [details] [diff] [review]
Removed argc test

a=chofmann for 1.0.1  add fixed1.0.1 keyword after checking in on the branch
Attachment #89973 - Flags: approval+
I'll check in.

/be
Fixed on the branch, too.

/be
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified FIXED. Testcase corrected:

         mozilla/js/tests/ecma/Array/15.4.4.3-1.js


This now passes in the debug/optimized JS shells. It also passes
in the rhino/rhinoi shells, since Roger also made the fix there. 
Also fixed on MOZILLA_1_0_BRANCH; adding verified1.0.1 keyword -
Status: RESOLVED → VERIFIED
Keywords: verified1.0.1
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: