Closed
Bug 604971
Opened 15 years ago
Closed 15 years ago
array.sort compare-function gets incorrect this
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
| Tracking | Status | |
|---|---|---|
| blocking2.0 | --- | beta7+ |
People
(Reporter: evilpies, Assigned: evilpies)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(2 files)
|
189 bytes,
application/x-javascript
|
Details | |
|
837 bytes,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
Since the es5 and strict mode, "null" and "undefined" this is observable.
As defined by es5 compare function should get "null" as their |this| value;
Test:
[1, 2].sort(function () {
"use strict";
if (this === undefined)
throw;
});
Comment 1•15 years ago
|
||
Did you mean that the compare function should be passed undefined as |this|? That's what I'm reading in 15.4.4.11:
"Return the result of calling the [[Call]] internal method of comparefn passing undefined as the this value and with arguments x and y."
Regardless, the bug summary is correct: we are currently passing null instead of undefined.
| Assignee | ||
Comment 2•15 years ago
|
||
Right totally messed it up, but i originally meant the right thing.
Currently the compare-function gets "null" but it should be "undefined".
| Assignee | ||
Comment 3•15 years ago
|
||
| Assignee | ||
Comment 4•15 years ago
|
||
Attachment #483856 -
Flags: review?
| Assignee | ||
Updated•15 years ago
|
Attachment #483856 -
Flags: review? → review?(lw)
Comment 5•15 years ago
|
||
Comment on attachment 483856 [details] [diff] [review]
micro fix
Stealing, this micro-fix is easy enough. Looks like I forgot about this instance of this-passing when I wrote the strict-this patches...
I'll push this into TM tomorrow morning. I can imagine we might want this for the beta release, on the principle of avoiding pointless dups for a very obvious mistake in new functionality for anyone looking, but I'm not going to push it.
Attachment #483856 -
Attachment is patch: true
Attachment #483856 -
Attachment mime type: application/octet-stream → text/plain
Attachment #483856 -
Flags: review?(lw) → review+
Comment 6•15 years ago
|
||
Assignee: general → evilpies
Status: NEW → ASSIGNED
blocking2.0: --- → ?
OS: Windows XP → All
Hardware: x86 → All
Whiteboard: fixed-in-tracemonkey
Comment 7•15 years ago
|
||
(Thanks for the patch!)
Updated•15 years ago
|
blocking2.0: ? → beta8+
Updated•15 years ago
|
Blocks: strictThis
Comment 8•15 years ago
|
||
blocking2.0: beta8+ → beta7+
Updated•15 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•