Closed
Bug 664528
Opened 14 years ago
Closed 12 years ago
array.sort bug with arrays containing only undefined values
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla21
People
(Reporter: jandem, Assigned: Waldo)
References
Details
Attachments
(1 file)
2.13 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
--
var a = [, , , undefined];
a.sort();
for (var i=0; i<a.length; i++) {
if (!(i in a)) {
print("Hole: " + i);
} else if (a[i] === undefined) {
print("Undefined: " + i);
}
}
--
This prints:
--
Hole: 0
Hole: 1
Hole: 2
Undefined: 3
--
This is incorrect. Quoting ES5: "non-existent property values always compare greater than undefined property values". Works correctly if I add a value other than undefined to the array.
Assignee | ||
Comment 1•12 years ago
|
||
I happened to notice this in a skim through all JS bugs today, searching for a substring in the summaries. Having just reviewed bug 715419, this code's super-fresh in memory, so I looked and found the easy fix. Haven't run JS tests yet, but I'm 99% sure this is a complete fix.
Reporter | ||
Comment 2•12 years ago
|
||
Comment on attachment 713700 [details] [diff] [review]
Patch and test
Review of attachment 713700 [details] [diff] [review]:
-----------------------------------------------------------------
Heh, thanks, completely forgot about this bug.
Attachment #713700 -
Flags: review?(jdemooij) → review+
Assignee | ||
Comment 3•12 years ago
|
||
Target Milestone: --- → mozilla21
Comment 4•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•