Closed
Bug 178722
Opened 22 years ago
Closed 22 years ago
calling Array.sort() on an empty array returns undefined instead of an empty array
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
People
(Reporter: tommy, Assigned: rginda)
Details
(Keywords: js1.5)
Attachments
(2 files, 1 obsolete file)
575 bytes,
patch
|
brendan
:
review+
asa
:
approval+
|
Details | Diff | Splinter Review |
2.49 KB,
patch
|
brendan
:
review+
jesup
:
approval+
|
Details | Diff | Splinter Review |
I am using Mozilla 1.2b but the form did not have an option for that. The following code illustrates the problem: var empty = new Array(); var filled = new Array('d', 'b', 'a', 'x', 'g'); alert(empty.length); alert(filled.length); empty = empty.sort(); filled = filled.sort(); alert(typeof(empty)); alert(typeof(filled));
Comment 1•22 years ago
|
||
Updated•22 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Comment 2•22 years ago
|
||
Testcase added to JS testsuite: mozilla/js/tests/js1_5/Array/regress-178722.js Currently passing in Rhino, but not in SpiderMonkey. Will test out patch next. Meanwhile, cc'ing reviewers -
Comment 3•22 years ago
|
||
The patch makes the testcase pass. It also passes the JS testsuite in the optimized shell on WinNT. No test regressions are observed. Here is how the reporter's example behaves in the patched JS shell: js> var empty = new Array(); js> empty.length; 0 js> empty = empty.sort(); js> typeof empty; object js> empty instanceof Array; true js> empty.length; 0
Comment 4•22 years ago
|
||
Comment on attachment 105383 [details] [diff] [review] Return original array when length == 0 r=brendan@mozilla.org, this is good for the trunk now. Thanks, /be
Attachment #105383 -
Flags: review+
Comment 5•22 years ago
|
||
Fixed with rogerl credit, I couldn't wait. This should go onto the 1.0 branch too, ASAP for 1.0.2. /be
Comment 6•22 years ago
|
||
Comment on attachment 105383 [details] [diff] [review] Return original array when length == 0 a=asa for checkin to the 1.2 branch (on behalf of drivers)
Attachment #105383 -
Flags: approval+
Comment 7•22 years ago
|
||
How about for 1.0.2, i.e., to the 1.0 branch? /be
Comment 8•22 years ago
|
||
Apologies to Roger and Asa; I'm the source of the confusion here. Now I understand; we're looking for this fix to go into: 1. The trunk (done already) 2. -rMOZILLA_1_0_BRANCH And it's OK if it goes into -rMOZILLA_1_2_BRANCH also.
Comment 9•22 years ago
|
||
Forgot to say that I did check into the 1.2 branch, it's good there too. /be
Comment 10•22 years ago
|
||
Adding adt1.0.2 to make sure it's on their radar. Brendan and I are strongly in favor of this for 1.0.2, and for blackbird as well so web designers don't have to worry as much about compatibility. Extremely low risk.
Keywords: adt1.0.2
Comment 11•22 years ago
|
||
Comment on attachment 105383 [details] [diff] [review] Return original array when length == 0 a=rjesup@wgate.com for 1.0 branch (since it's not clear whether Asa approved it for 1.0 or 1.2)
Updated•22 years ago
|
Keywords: mozilla1.0.2 → mozilla1.0.2+
Comment 12•22 years ago
|
||
Discussed in team meeting. Minusing for blackbird. We don't know where sort is used in our own chrome and don't know what code might depend on this bug. If we were to take this we would have to restart certification.
Comment 13•22 years ago
|
||
> We don't know where sort is used in our own chrome
Then use lxr.mozilla.org and the netscape.com commercial tree equivalent to find
all sort( calls in chrome. You won't find any that depend on this bug, and you
don't need to "restart certification" to take this change, but I give up if you
really insist on shipping this bug.
As IE has no such bug, it is unlikely anything on the web counts on the broken
behavior of SpiderMonkey (which regressed in June of 2000).
However, mozilla1.0.2 will have this fix.
/be
Comment 14•22 years ago
|
||
Here's a URL for all the .sort() calls in the mozilla tree: http://lxr.mozilla.org/seamonkey/search?string=%5C.sort%5C%28%5C%29 (i.e. search for "\.sort\(\)") There are around 10 that aren't testcode, non-default extensions, or calls to C++ sort() functions.
Comment 15•22 years ago
|
||
jesup: thanks -- http://lxr.mozilla.org/seamonkey/search?string=%5C.sort%5C%28 is a better link, as sort may have an optional compare-func parameter passed to it. Only the venkman/cview/irc extensions use the return value of sort, and rginda and I just looked at the venkman ones (Netscape doesn't care about the others). All the venkman sorts happen on non-empty arrays. So there is no need to re-QA a bunch of stuff, if Netscape takes this change. /be
Assignee | ||
Comment 16•22 years ago
|
||
It turns out there is one place in venkman that would throw an exception because of this change, but it wouldn't have worked correctly before the change either. A patch is coming up that makes venkman work properly regardless of whether or not this bug is fixed.
Assignee | ||
Comment 17•22 years ago
|
||
Comment 18•22 years ago
|
||
Comment on attachment 105882 [details] [diff] [review] venkman fix >@@ -803,7 +810,8 @@ > { > var jsdFrame = console.frames[e.frameIndex]; > >- displayFrame (jsdFrame, e.frameIndex, true); >+ if ("insInteractive" in e && e.isInteractive) Oops -- "isInteractive" was fat-fingered. Fix that and r=me. /be
Attachment #105882 -
Flags: review+
Assignee | ||
Comment 19•22 years ago
|
||
Attachment #105882 -
Attachment is obsolete: true
Comment 20•22 years ago
|
||
Comment on attachment 105998 [details] [diff] [review] venkman fix, take two. r=me still. /be
Attachment #105998 -
Flags: review+
Comment 21•22 years ago
|
||
I checked into the 1.0 branch. rginda, over to you to get the venkman patches into whatever branches need 'em. /be
Assignee: rogerl → rginda
Status: ASSIGNED → NEW
Comment 22•22 years ago
|
||
Comment on attachment 105998 [details] [diff] [review] venkman fix, take two. approved for 1.2
Attachment #105998 -
Flags: approval+
Comment 23•22 years ago
|
||
a=rjesup@wgate.com for venkman fix for the 1.0 branch as well, assuming it needs it.
Assignee | ||
Comment 24•22 years ago
|
||
Comment on attachment 105998 [details] [diff] [review] venkman fix, take two. checked in to 1.0 and 1.2 branches. Will check in to trunk when it opens.
Comment 25•22 years ago
|
||
It looks like Rob was able to check in the trunk Venkman changes today. 1. I have verified the jsarray.c bugfix in Comment #3 above. 2. I have verified the jsarray.c checkin on all three branches: -rHEAD, -rMOZILLA_1_0_BRANCH, -rMOZILLA_1_2_BRANCH 3. I have verified the Venkman checkins on all three branches So we can mark this bug FIXED now, right?
Assignee | ||
Comment 26•22 years ago
|
||
sounds fixed to me.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Updated•19 years ago
|
Flags: testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•